|
Here is my code i am using to try to understand how to pass parm to other asp.net pages.
I can pass them into a page but iam unable to use the Response.Redirect correctly.
<%@ Page Language="VB" Debug="true" %>
<script runat="server">
Sub Page_Load(Sender as Object, e as EventArgs)
if not request.querystring("inputtext") = nothing then
lblMsg.Text = "You entered: " & request.querystring("inputtext")
else
lblMsg.Text = "Nothing Input"
end if
if not request.querystring("inputtext2") = nothing then
lblMsg2.Text = "You entered: " & request.querystring("inputtext2")
else
lblMsg2.Text = "Nothing Input"
end if
End Sub
Sub btnOnClick(Sender as Object, e as EventArgs)
Response.Redirect("/forum/passpram2_inputtext_.html" & tbInput.Text,"inputtext2=" & tbInput2.Text )
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:Label id="lblMsg" runat="server"></asp:Label>
<br />
<asp:textbox id="tbInput" runat="server"></asp:textbox>
</p>
<p>
<asp:Label id="lblMsg2" runat="server">lblMsg2</asp:Label>
</p>
<p>
<asp:TextBox id="tbInput2" runat="server"></asp:TextBox>
</p>
<p>
<br />
<asp:button id="Button1" onclick="btnOnClick" runat="server" text="Submit"></asp:button>
</p>
</form>
</body>
</html>
---------------------------------------------------------------------------------------------
Response.Redirect("/forum/passpram2_inputtext_.html" & tbInput.Text,"inputtext2=" & tbInput2.Text )
here is a test using the adress bar to work. http://localhost:8080/passpram2.aspx?inputtext=text1 &inputtext2=text2
The parms pass. The redirect
Is my format in error? Any help would be welcome.
|
|
|
Here's how I think it should look:
Response.Redirect("/forum/passpram2_inputtext_.html" & tbInput.Text & "&inputtext2=" & tbInput2.Text )
|
|
|
Exactly: QueryString key-value pairs are separated from the URL by a question mark, and from each other by an ampersand. When your code is interpreted, it should result in a URL that looks like:
As an alternative, you can pass all of your ASP.NET webform data via POST rather than GET, to a second ASP.NET webform, by using the more powerful "Server.Transfer()" method.
|
|
|
|
|
|
|
|
|
|