.Net, ASP.Net, C#, VB.net, SQL Server, Xml, CSS, Design Patterns related tips, tricks, code snippets, articles, links, thoughts, etc. from Binu & Subi Thayamkery.

Binu Thayamkery is a seasoned software architect with more than 13 years of experience in developing enterprise grade connected systems using Microsoft Technologies. In his current position as a lead consultant-solution architect with Prudential Financial, he is working on architecture of next generation investment reporting framework using .net 3.5/WCF/AJAX, etc. He holds a Masters Degree in Computer Science from Colorado State University. Subi Thayamkery is an experienced software developer with more than 8 years of developing various application software systems ranging from workflow automation systems to compliance management tools. She currently works as a technology consultant for Prudential Financial where she helps develop a new system for corportate governance department. She holds an Electrical Engineering degree from New Jersey Institute of Technology.

Thursday, January 19, 2006

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
{
get
{
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;



}
}

0 comments: