Server.Transfer and Page to Page data exchange

When you are using Server.Transfer to transfer control from one page to another page within the same HttpContext, you can use Context property of Current (http context) to get a handle of the parent page. Once you have that you can access properties (public) of that page. Key thing to remember is that all ASP.Net pages are classes! (derived from mama Page Class )

Here is a simple illustration:

Your first page:

public class FirstPage: System.Web.UI.Page

public int MyInt
return (1);


Your second page:

public class SecondPage: System.Web.UI.Page
private void Page_Load(object sender, System.EventArgs e)
if (!Page.IsPostBack)
int myParentInt;
FirstPage myParentPage;
myParentPage = (FirstPage)Current.Handler;
myParentInt = myParentPage.MyInt;


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s