Possible Duplicate:
Send data from one page to another in C# ASP.Net
Hi I am trying to send data from one page to another in asp.net I found various methods of doing so and am gona try a few to se how they work but I seem to be getting an error on my first attempt.Here is my code:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<asp:Button ID="Button1" runat="server" Text="Go"
PostBackUrl="~/Default2.aspx" />
<br />
I am sending the data from Default.aspx to Default2.aspx. At the Default2.aspx in the Page_Load method I wrote this to retrieve the data:
if (Page.PreviousPage != null)
{
string txtBox1 = ((TextBox)Page.PreviousPage.FindControl("TextBox1")).Text;
}
From what I read on MSDN this should work but I must be missing something because when I pres the button to send the data and Default2.aspx loads I get an error page that looks like this: