C#/asp.net geting error when sending data from one page to another

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:\[code\]<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /><asp:Button ID="Button1" runat="server" Text="Go" PostBackUrl="~/Default2.aspx" /><br />\[/code\]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:\[code\] if (Page.PreviousPage != null) { string txtBox1 = ((TextBox)Page.PreviousPage.FindControl("TextBox1")).Text; }\[/code\]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:
ZMIxh.png
qS95j.png
 
Back
Top