I have a page where a user enters some basic info (name, email address, etc.), then they click Submit.
I then display a confirmation page. I want to display text that says something like "Thanks Dave, we got your info".
In the info form page, I'm doing this when Submit is clicked:
Sub ConfirmMsg()
Dim name As String
name = txName.Text
Response.Redirect("free_cvi_confirm.aspx?name")
End Sub
Here is the Page_Load function on the confirmation page:
Private Sub Page_Load(ByVal .....)
Label1.Text = "Thanks " + Request.QueryString("name") + ", we got your info"
End Sub
This displays nothing when Label1 displays. And when I look in Request.QueryString, I also can't find the name value.
What am I doing wrong? I've tried a few different variations, but can't seem to hit it. Thanks in advance for your great help.
DaveHello, in the page where u submit the form the conform message page should be like this:
Protected Sub ConfirmMsg(ByVal sender As Object, ByVal e As EventArgs)
Dim name As String = String.Empty
name = txName.Text
Response.Redirect("free_cvi_confirm.aspx?name=" + name)
End Sub
In the second page:
Protected Sub Page_Load(ByVal src As Object, ByVal e As EventArgs)
Label1.Text = "Thanks " + Request.QueryString("name").ToString() + ", we got your info"
End Sub
Good Luck.
HI davehunt,
Welcome the asp.net forums...
Use this
Response.Redirect("free_cvi_confirm.aspx?name=" & name)
thatz it
I believe that the 2 methods suggested so far place the values of the variables in the querystring (and then retrieve the values from the querystring). If having the variables visible in the querystring is acceptable, then I don't see any reason not to use those methods.
However, if you want to "post" the variables instead use this...
In the first page:
<script runat="server">
Sub Submit(Sender as Object, e as EventArgs)
Server.Transfer("http://path/page2.aspx")
End Sub
</script>
<html>
<body>
<form runat="server">
<asp:TextBox ID="tbName" Runat="server" />
<br>
<asp:Button Text="Submit" Runat="server" OnClick="Submit" />
</form>
</body>
</html
In the second page:
<script runat="server">
Sub Page_Load(Sender as Object, e as EventArgs)
lblName.Text = Request.Form("tbName")
End Sub
</script>
<html>
<body>
<form runat="server">
Name =
<asp:Label id="lblName" Runat="server" />
</form>
</body>
</html
Hope this helps,
Rob
Thanks guys, this was a big help.
Dave
0 comments:
Post a Comment