C#/asp.net geting error when sending data from one page to another
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/12768674/send-data-from-one-page-to-another-in-c-sharp-asp-net">Send data from one page to another in C# ASP.Net</a>  </p>
</blockquote>



<p>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:</p>

<pre><code>&lt;asp:TextBox ID="TextBox1" runat="server"&gt;&lt;/asp:TextBox&gt;
&lt;br /&gt;
&lt;asp:Button ID="Button1" runat="server" Text="Go" 
    PostBackUrl="~/Default2.aspx" /&gt;
&lt;br /&gt;
</code></pre>

<p>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:</p>

<pre><code>  if (Page.PreviousPage != null)
    {
        string txtBox1 = ((TextBox)Page.PreviousPage.FindControl("TextBox1")).Text;
    }
</code></pre>

<p>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:</p>

<p><img src="http://i.stack.imgur.com/ZMIxh.png" alt="enter image description here">
<img src="http://i.stack.imgur.com/qS95j.png" alt="enter image description here"></p>
