' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If
Dim MM_editAction Dim MM_abortEdit Dim MM_editQuery Dim MM_editCmd
Dim MM_editConnection Dim MM_editTable Dim MM_editRedirectUrl Dim MM_editColumn Dim MM_recordId
Dim MM_fieldsStr Dim MM_columnsStr Dim MM_fields Dim MM_columns Dim MM_typeArray Dim MM_formVal Dim MM_delim Dim MM_altVal Dim MM_emptyVal Dim MM_i
MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME")) If (Request.QueryString <> "") Then MM_editAction = MM_editAction & "?" & Server.HTMLEncode(Request.QueryString) End If
' boolean to abort record edit MM_abortEdit = false
' query string to execute MM_editQuery = "" %> <% ' *** Insert Record: set variables
' create the MM_fields and MM_columns arrays MM_fields = Split(MM_fieldsStr, " ¦") MM_columns = Split(MM_columnsStr, " ¦")
' set the form values For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2 MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i))) Next
' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If
我查了一些资料,把 append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If 中红色的部分改为request.form,就可以把希望传递的值加到URL后传递到B页面,但是如何在B页中获取这个值呢?
现在,打开你的代码来看,会发现下面的代码。这段代码在每个 MM “Insert” 或者 “Update Record” 页面中是相同的:
' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.QueryString <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString End If End If 红色的代码是我们将要修改的有问题的代码。MM通过绑定数据到新地址并将这些表单元素传递到下一页,然而,Request.QueryString 是这样一种代码:在表单以“GET”方式传递数据时,将所有数据绑定到URL中“?”之后。所以当MM使用POST方式传递数据时,Request.QueryString是空的。因此为了得到“?”后面所有内容的值我们需要使用用“Request_Form”.
步骤2:用下面所示的 Request.Form 代替上面所有的红色代码。
' append the query string to the redirect URL If (MM_editRedirectUrl <> "" And Request.Form <> "") Then If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.Form <> "") Then MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.Form Else MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.Form End If End If 步骤3:现在可以使用
If MM_editRedirectUrl <> "" And Request.form("需要传递的form键") <>"" Then MM_editRedirectUrl = MM_editRedirectUrl & "?a=" & Request.form("需要传递的form键") Else MM_editRedirectUrl = MM_editRedirectUrl &"?a=NULL" End If