页面之间传递元素的办法
发布时间:2006-10-14 2:45:19   收集提供:gaoqian
在第三方页面传递参数这个思路倒是的确可以省下一些代码,至少我以前是从没这样子传过。
<%
    '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
%>
原来可以整个抓取的,我也是刚刚知道,不敢独吞,拿出来共享


 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50