For one of my clients I have to pass /transmit data from one aspx page to another.Though I can use I was Session , hidden fields,Request.QueryString() for this, i was curious to know whether I can leverage ASP.NET 2.0 features to achieve this.After little bit of googling I have found that with the use of postbackurl property of a submit button and adding a
<%@ PreviousPageType VirtualPath="~/My Web Site/source.aspx" %> directive we can manipulate the information in the target page.in the code behibnd page we have to write the follow. using the Page.PreviousPage property: here i have used the master page concept and based on the ContentPlaceHolder id of the master page , I am finding the controls listed in the source page
if (PreviousPage != null && PreviousPage.IsCrossPagePostBack && PreviousPage.IsValid)
if ((PreviousPage.Master != null))
labelError.Visible = false;
ContentPlaceHolder cph1 = (ContentPlaceHolder)Page.PreviousPage.Master.FindControl("cph");
if (cph1 != null)
ListBox lstCountry = (ListBox)cph1.FindControl("lstCountry"); //lstCountry is a control the source.aspx page.
now you can access the selecteditems/ its value or or its index as we do in the normal way.
if (lstCountry.SelectedItem.Text == "--All--" && tlstCountry.Items.Count >0)
//do some process here.
in the source.aspx page file if there exists a submit button / hyperlink button
the concept is known as CrossPage Postback , a new feature introduce din ASP.NET 2.0.!!!!