Saturday, June 2, 2012

Cross Page Posting In asp.net



ASP.NET by default, submits the form to the same page. Cross page posting is submitting the form to a different page. This is usually required when you are creating a multi page form to collect information from the user on each page. When moving from the source to the target page, the values of controls in the source page can be accessed in the target page.

To use cross-page posting, you have to use the PostBackURL attribute to specify the page we want to post to.

1st Page :

<asp:Button ID="btnCrosspage" runat="server" PostBackUrl="~/Default2.aspx" Text="Target Page" />

2nd Page :

protected void Page_Load(object sender, EventArgs e)

{

  if (Page.PreviousPage != null)
  {

   TextBox txtNoOfDays=(TextBox) PreviousPage.FindControl("txtNoOfDays");
  }

No comments:

Post a Comment

Comments

Search

Custom Search
Protected by Copyscape Plagiarism Software