Enter a value to post: <asp:textbox id="TextBox1" runat="Server"> </asp:textbox> <br /> <br /> <asp:button id="Button1" text="Post back to this page" runat="Server"> </asp:button> <br /> <br /> <asp:button id="Button2" text="Post value to another page" postbackurl="PostBackUrlPage2cs.aspx" runat="Server"> </asp:button>
void Page_Load(object sender, System.EventArgs e) { string text; // Get the value of TextBox1 from the page that // posted to this page. text = ((TextBox)PreviousPage.FindControl("TextBox1")).Text; // Check for an empty string. if (text != "") PostedLabel.Text="The string posted from the previous page is "+text+"."; else PostedLabel.Text = "An empty string was posted from the previous page."; }
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
FindControl
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)