当前位置: 首页 > 图文教程 > 网络编程 > ASP > 页面之间传递元素的办法

ASP
连接数据库查询手册
ASP.net组件编程中的两种事件编写方法
简单快捷实现ASP在线发邮件
ASP能读写注册表
用ASP实现在线压缩与解压缩
Asp编写不再让人讨厌的自动弹出窗口
使用组件封装ASP的数据库操作
删除Access数词库中的空记录
制做行背景颜色交替变换的表格
将数据库中的信息存储至XML文件中
如何用foreach遍历页面上所有的TextBox
asp.net如何生成图片验证码(简单)
WEB表格导出为EXCEL文档的方法
ASP上两个防止SQL注入式攻击Function
xmlHTTP技术资料
提高ASP.NET性能的方法
DataGrid 分页问题
如何固定表格的标题行和标题列
在B/S系统中引入定时器的功能
关于用ASP.Net识别远程主机服务器种类

ASP 中的 页面之间传递元素的办法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 91 ::
收藏到网摘: n/a

  在第三方页面传递参数这个思路倒是的确可以省下一些代码,至少我以前是从没这样子传过。
<%
    'Pass form objects submitted by a form G
    '     ET
    If Request.QueryString.Count>0 Then
    QStr="?"
    For Each x In Request.QueryString
    QStr = QStr & x & "="    'Write Name of Parameter
    QStr = QStr & Server.URLEncode(request.QueryString(x)) & "&" 'Write value of parameter
    Next
    QStrSz = len(QStr)-1
    QStr = LEFT(QStr,QStrSz)
    else
    QStr=""
    End If
    Response.Redirect("YourURL.asp" & QStr)
    %>
    The Next example shows how To build the submitted parameters from a form POST. The procedure reads all posted objects and builds a querystring parameter.
    <%
    'Pass form objects submitted by a form G
    '     ET
    If Request.form.Count>0 Then
    QStr="?"
    For Each x In Request.form
    QStr = QStr & x & "="    'Write Name of Parameter
    QStr = QStr & Server.URLEncode(request.form(x)) & "&" 'Write value of parameter
    Next
    QStrSz = len(QStr)-1
    QStr = LEFT(QStr,QStrSz)
    else
    QStr=""
    End If
    Response.Redirect("YourURL.asp" & QStr)
    %>
    The Next code example may be used as a test ASP page To redirect to. It reads the querystring and builds a table to display the parameter name and value passed.
    <%@ Language=VBScript %>
    <HTML>
    <BODY>
    <%
    Response.Write "<TABLE BORDER=1><TR><TH>Parameter</TH><TH>Value</TH></TR>"
    For Each x In Request.QueryString
    Response.write "<TR><TD>" & x & "</TD><TD>" 'Write Name of Parameter
    Response.write Request.QueryString(x) & "</TD></TR>" 'Write value of parameter
    Next
    Response.Write "</TABLE>"
    %>
    </BODY>
    </HTML>
当然,上面这个东西的改进版本就简洁多了,再看这个
<%
If
Request.QueryString.Count > 0 Then
  
Response.Redirect("YourURL.asp?" &
Request.QueryString
Else
  If
Request.Form.Count > 0 Then
    
Response.Redirect("YourURL.asp?" &
Request.Form)
  Else
    
Response.Write("No Data Sent")
  End
If
End If
%>
原来可以整个抓取的,我也是刚刚知道,不敢独吞,拿出来共享