Vanita

Vanita

  • NA
  • 74
  • 3.8k

What is cross page-posting?

Feb 24 2019 6:52 AM
A cross-page postback is a technique that extends the postback mechanism you’ve already learned about so that one page can send the user to another page, complete with all the information for that page. This technique sounds conceptually straightforward, but it’s a potential minefield. If you’re not careful, it can lead you to create pages that are tightly coupled to others and difficult to enhance and debug. The infrastructure that supports cross-page postbacks is a property named PostBackUrl, which is defined by the IButtonControl interface and turns up in button controls such as ImageButton, LinkButton, and Button. To use cross-posting, you simply set PostBackUrl to the name of another web form. When the user clicks the button, the page will be posted to that new URL with the values from all the input controls on the current page. (This posted-back information includes the hidden view-state field. As you’ll see shortly, it allows ASP.NET to create an up-to-date instance of the source page in memory.) Here’s an example—a page named CrossPage1.aspx that defines a form with two text boxes and a button. When the button is clicked, it posts to a page named CrossPage2.aspx. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="CrossPage1.aspx.cs" Inherits="CrossPage1" %>
 



Answers (3)