cross page posting asp.net not returning values
<p>I have a web form as </p>

<pre><code>&lt;asp:TextBox ID="txtname" runat="server" Text="Post on Next Page"/&gt;
&lt;asp:Button ID="btn1" runat="server" PostBackUrl="~/Page2.aspx" Text="Post on next page" /&gt;
</code></pre>

<p>Now on <code>Page2.aspx</code> the code-behind is as follows:</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
{
   if(PreviousPage!=null &amp;&amp; PreviousPage.IsCrossPagePostBack)
   {
       TextBox txt1 = (TextBox)PreviousPage.FindControl("txtname");
       label1.Text = "Value: " + txt1.Text;
   }
}
</code></pre>

<p>I end up getting the error <code>object reference not set to instance of an object</code> for <code>txt1</code></p>

<p>Where <code>label1</code> is a label used to display the output. However, the value is not displayed.</p>

<p>What step am i missing?</p>
