• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

Displaying All of the Form Variables

发布: 2007-6-30 18:56 | 作者: admin | 来源: | 查看: 16次 | 进入软件测试论坛讨论

领测软件测试网 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




That@#s it! To call the function, simply use:

Call FormDataDump(TrueOrFalse, TrueOrFalse)  

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网