Cross Page Posting In ASP.NET

By Mahak Gupta Feb 29, 2012
We use the concept of CrossPage Posting, when we collect the data from one web page and this data is used on another webpage.

We use the concept of CrossPage Posting, when we collect the data from one web page and this data is used on another webpage.

We use the PreviousPage property of the Page object to access the data from the first page.

We can access any of the controls of the previous page by using the FindControl Method.

Here we take an example in which we take a Label( Label1 ) to show the previos page data( txtfname) in it.

 

if (PreviousPage == null)

{

 Label1.Text="There are no data in the previous page";

}

else

{

 Label1.Text = ((TextBox)PreviousPage.FindControl("txtfname")).Text;

 }

 

 

Note:

The Crosspage posting occurs where there are any data avaliable in the previous page and if there is no data in the previous page we set it

if (PreviousPage == null)

so there are no cross page posting occurs in this case.

 

Mahak Gupta

My name is Mahak Gupta. I am a C# Corner MVP.

COMMENT USING

PREMIUM SPONSORS

Hire Mobile & Web Developer on demand. 100% satisfaction. Try for 1 week or Money Back. Local and remote developers available all over USA.

Latest Blogs