Into asp.net by default submit the form to the same page. And cross-page posting is submitting the form to a different page. It is usually required when you are creating a multi-page form to collect information from the user on each page. As moving from the source to the target page, the values of controls in the source page can be accessed in the target page. If you want to use cross-page posting, you have to use the PostBackURL attribute to specify the page you want to post to.
Step 1: Select a new in visual studio(C# and asp.net) website called CrossPagePosting. By default, the website is created with a single webpage, Default.aspx.
Right-click the project in the Solution Explorer > Add New Item >Web Form.
Hold the original name Default2.aspx and click ‘Add’. The website will now contain two pages, Default.aspx and Default2.aspx.
Step 2: Through the source page, Default.aspx, drop a button on the form. Set the text of the button as ‘TargetButton’. And set the ‘PostBackUrl’ property of a Button to the URL of the target page, Default2.aspx.
Step 3: Into the target page Default2.aspx, drop a label on the page from the toolbox.
Step 4: In the Page_Load() of Default2.aspx, you can then access the ‘PreviousPage’ property to check if the page is being accessed as Cross Page postback.
Step 5: By retrieve values from the source page, you must access controls using the ‘FindControl()’ method of the ‘PreviousPage’. We will be accessing the Text property of the Button control placed in Default.aspx.
Step 6: Into the Solution Explorer, Right-click Default.aspx > ‘Set as Start Page’. Run the application and click on the button. As you can observe, the page is posted to Default2.aspx and the value containing the name of the button control gets displayed in the label.
Liked By
Write Answer
Cross Page Posting
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
25-Jan-2019Into asp.net by default submit the form to the same page. And cross-page posting is submitting the form to a different page. It is usually required when you are creating a multi-page form to collect information from the user on each page. As moving from the source to the target page, the values of controls in the source page can be accessed in the target page. If you want to use cross-page posting, you have to use the PostBackURL attribute to specify the page you want to post to.
Step 1: Select a new in visual studio(C# and asp.net) website called CrossPagePosting. By default, the website is created with a single webpage, Default.aspx.
Step 2: Through the source page, Default.aspx, drop a button on the form. Set the text of the button as ‘TargetButton’. And set the ‘PostBackUrl’ property of a Button to the URL of the target page, Default2.aspx.
Step 3: Into the target page Default2.aspx, drop a label on the page from the toolbox.
Step 4: In the Page_Load() of Default2.aspx, you can then access the ‘PreviousPage’ property to check if the page is being accessed as Cross Page postback.
Step 5: By retrieve values from the source page, you must access controls using the ‘FindControl()’ method of the ‘PreviousPage’. We will be accessing the Text property of the Button control placed in Default.aspx.
Step 6: Into the Solution Explorer, Right-click Default.aspx > ‘Set as Start Page’. Run the application and click on the button. As you can observe, the page is posted to Default2.aspx and the value containing the name of the button control gets displayed in the label.