Cross Page postback, public methods return null
Hi,
I am having problems with transferring data using cross-page. The public methods which supposed to return the value from the previous page textboxes, always returns null.
Code from the present page (CrossPage2) as follows:
public partial class CrossPage2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
lblinfo.Text = "You came from a page titled " +
PreviousPage.Title + "<br />";
CrossPage1 prevPage = Page.PreviousPage as CrossPage1;
if (prevPage != null)
{
lblinfo.Text += "You typed in this: " + prevPage.FullName;
}
else
{
//lblinfo.Text = "null";
}
}
}
}
Code from the previous page (CrossPage1) as follows:
public partial class CrossPage1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public TextBox FirstNameTextBox
{
get { return txtFirstName; }
}
public TextBox LastNameTextBox
{
get { return txtLastName; }
}
public String FullName
{
get { return txtFirstName.Text + " " + txtLastName.Text; }
}
}
Can someone please help me find out what's wrong here.
(I am using ASP.NET 4)
Thank you
Viki