Reputation: 55
I'm actually newbie in ASP.NET..
I've created 2 pages named Page1.aspx and Page2.aspx
so, I tried this method to Display the value that was entered on Textbox to another Page on the textbox
Here's the Code using vb.net
Page1
<asp:Button ID="Button1" class="proceed" runat="server" Text="Proceed" />
Protected Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
Response.Redirect("Page2.aspx?Value=" + Textbox1.Text)
End Sub
Page2
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
If (Request.QueryString("Value")) Then
Textbox1.Text = Request.QueryString("Value")
End If
End Sub
that is working on my webpage but the problem is:
on the Page2.aspx. I have a button that will Edit the value on the textbox that was received from the Page1.aspx.. but it doesn't... what should i do in order to edit the value on the textbox in Page2.aspx...
Thank you in advanced...
I hope this is a clear question for you guys
Upvotes: 1
Views: 1758
Reputation: 126
On each postback to server the Page_Load method will call again,so when you click the button before your Button_Click method, the Page_Load method will execute and it will modify the textbox value. try this:
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
if (Page.IsPostBack) Then return;
If (Request.QueryString("Value")) Then
Textbox1.Text = Request.QueryString("Value")
End If
End Sub
running website with breakpoins could help you to figure out the problem.
Upvotes: 1