I want to pass the value of TextBox1 from one page to another using PostBackUrl. So here is the code for the first page.
<form id="form1" runat="server">
<div>
<h2>Working With the Previous Page Object</h2>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" PostBackUrl="~/Default7.aspx"/>
</div>
</form>
Now, here is the code for the page that retrieves the value from the First Page:
protected void Page_Load(object sender, EventArgs e)
{
Page previousPage = Page.PreviousPage;
if(previousPage != null)
{
Label1.Text = ((TextBox)previousPage.FindControl("TextBox1")).Text;
}
}
Off course I have inserted a Label called "Label1" on the page that retrieves the value of TextBox1 from the First Page.
I have seen lots of Tutorials doing exactly the same thing, but it just does not work for me, I do not know why. Any help is welcomed.