Cross Page Posting

Posted by Venkat | Labels:

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 you want to post to.

First we place the two page Default.aspx and Default2.aspx , so now we are going to pass the Controls value from default page to default2 page.

in Default.aspx page place one button and Textbox Control as shown below


<:TextBox ID="TextBox1" runat="server" Text="Welcome to .NET"></asp:TextBox>

<asp:Button ID="Button1" runat="server" PostBackUrl="~/Default.aspx" Text="TargetButton" />

And in the Default2.aspx page write the below code on page load and also make sure you have to place the label control on this page


<asp:Label ID="Label1" runat="server" ></asp:Label>

if (Page.PreviousPage != null)
{
TextBox btn = (TextBox)(Page.PreviousPage.FindControl("TextBox1"));
Label1.Text = btn.Text;
}

1 comments:

  1. Anonymous said...:

    Thanks you for maintaining such a wonderful collection of tweaks and crisp no-nonsense code snippets.

Post a Comment

Thanks for the Comments.

PayOffers.in