Reputation: 1411
I have a page1 and link on that page which opens up the Page2. There is a textbox on Page1 whose value needs to be passed onto the Page 2 when the user clicks on the link for Page2.
Firstly, I thought of using onTextbox changed event, but cant use that as the values in the textbox are autogenerated.
Once the Page1 is loaded the value in the textbox is 1 which needs to be passed onto Page2 when Page2 is clicked. i want to do this using querystring. inputs please.
Upvotes: 1
Views: 3869
Reputation: 460360
You could use a LinkButton and handle its click event in codebind. There you can Response.Redirect to Page2 and append the TextBox' Text to the QueryString.
Dim newLink as String = _
String.Format("Page2.aspx?TextBox1Text={0}", Server.HtmlEncode(TextBox1.Text))
Response.Redirect(newLink)
Upvotes: 1
Reputation: 20425
You could easily do that with a LinkButton. Handle the click event on the LinkButton for Page2, and then construct your Response.Redirect with the appropriate QueryString key/value pairs:
HTML:
<asp:TextBox ID="TextBox1" runat="server" />
<asp:LinkButton ID="LinkButton1" runat="server" Text="Page2" />
CODE-BEHIND:
Private Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
Response.Redirect(String.Format("Page2.aspx?tb={0}", Server.HtmlEncode(TextBox1.Text)))
End Sub
Upvotes: 1
Reputation: 717
Why not use POST and Server.Transfer?
Using Server.Transfer then you can get access to all form properties from the previous page.
http://msdn.microsoft.com/en-us/library/ms525800%28v=vs.90%29.aspx
Upvotes: 0