Cross Page Posting In ASP.NET

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.