Cross-Page Posting
I have tried a simplified version of cross-page posting based on listings 1-9 and 1-10 (pp. 27-29). I had one text box on each page, and a button in the first. In the first document I also had a hyperlink to the second page.
Two things happened that I found surprising.
(1) The second page displaced the first page from the browser as soon as the data were transferred.
(2) When I returned to the first page and clicked on the hyperlink to the second, I got an error message, of which the following is an extract:
"Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 16: protected void Page_Load(object sender, EventArgs e)
Line 17: {
Line 18: TextBox pp_TextBox1 = (TextBox)PreviousPage.FindControl("TextBox1");
Line 19: TextBox1.Text = pp_TextBox1.Text;
Line 20: }"
This code is from the second page. Each text box is called "TextBox1" in its own page.
Is there any way I can prevent either of these behaviors from happening?
Thank you for your trouble.
Roman
|