欢迎光临
我们一直在努力

Displaying All of the Form Variables

建站超值云服务器,限时71元/月

when debugging asp pages it can be very useful to see exactly what data is being sent when a form is posted. for that reason, i decided to create a handy little function that will display all of the form variable names and values. this function, formdatadump() has the following definition:

sub formdatadump(bolshowoutput, bolendpageexecution)  

these two input parameters are boolean values. bolshowoutput, if true, will dump out the form field names and values for all to see. this has the effect of making your html page uglier and harder to read – therefore, if you are testing on a live site, you should set this value to false, in which case the form field names and values will be outputted inside of an html comment tag (<!– form field names and values –>), so that they can only be seen via a view/source.

the second parameter, bolendpageexecution, determines whether or not a response.end is issued in the formdatadump() function. response.end, if issued, ends the processing of the asp page.

below you will find the complete code for the formdatadump() function.

sub formdatadump(bolshowoutput, bolendpageexecution)
  dim sitem

  what linebreak character do we need to use?
  dim strlinebreak
  if bolshowoutput then
    we are showing the output, so set the line break character
    to the html line breaking character
    strlinebreak = "<br>"
  else
    we are nesting the data dump in an html comment block, so
    use the carraige return instead of <br>
    also start the html comment block
    strlinebreak = vbcrlf
    response.write("<!–" & strlinebreak)
  end if
  

  display the request.form collection
  response.write("displaying request.form collection" & strlinebreak)
  for each sitem in request.form
    response.write(sitem)
    response.write(" – [" & request.form(sitem) & "]" & strlinebreak)
  next
  
  
  display the request.querystring collection
  response.write(strlinebreak & strlinebreak)
  response.write("displaying request.querystring collection" & strlinebreak)
  for each sitem in request.querystring
    response.write(sitem)
    response.write(" – [" & request.querystring(sitem) & "]" & strlinebreak)
  next

  
  if we are wanting to hide the output, display the closing
  html comment tag
  if not bolshowoutput then response.write(strlinebreak & "–>")

  end page execution if needed
  if bolendpageexecution then response.end
end sub

thats it! to call the function, simply use:

call formdatadump(trueorfalse, trueorfalse)  

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Displaying All of the Form Variables
分享到: 更多 (0)

相关推荐

  • 暂无文章