Home > Code > ASP.NET > How to retrieve public members of previous page values through context.handler in asp.net?

How to retrieve public members of previous page values through context.handler in asp.net?

by Thamil   on Oct 07, 2015   Category: ASP.NET   |  Views: 544    |  Points: 25   |  Gold 


Context.handler object is used to retrieve the public members from one web form to another web form. See the below sample code how to get the values from last page

Page1
public partial class context1 : System.Web.UI.Page
{
string UName = string.Empty;
public string Name
{
get
{
return UName;
}
}
protected void Page_Load(object sender, EventArgs e)
{
UName = "John";
}

protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("Context2.aspx");
}
}


Page2- Get the values in page load event
public partial class Context2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
context1 PreviousPage;
PreviousPage = (context1)Context.Handler;
Label1.Text = PreviousPage.Name;
}
}





Post Code  |  Code Snippet Home

User Responses


No response found, be the first to review this code snippet.

Submit feedback about this code snippet

Please sign in to post feedback

Latest Posts