I have two pages page1.aspx and page2.aspx, both have code behind with partial classes. How do i access public property message on page1.aspx from page2.aspx ?
I just read that the one is MasterPage and the other is the client to masterpage ? then its diferent way.
If you have 2 simple diferent pages. I have done it this way. Its a post value, by using asp.net tricks :)
On Page2.aspx add this on top.
<%@ PreviousPageType VirtualPath="Page1.aspx" %>
and how I read from Page1.aspx on code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Page.PreviousPage != null)
{
if(Page.PreviousPage.IsCrossPagePostBack == true)
{
txtGetItFromPreviusPage.Text = PreviousPage.SomeString;
}
}
}
}
On Page1.aspx the button that send me to Page2.aspx
and the code that I use for Page1 calculations or other thinks
public string SomeString
{
set
{
ViewState["txtSomeString"] = value;
}
get
{
if (ViewState["txtSomeString"] != null)
return ViewState["txtSomeString"].ToString();
else
return string.Empty;
}
}
protected void btnMoveSelection_Click(object sender, EventArgs e)
{
// some final calculations
}