Cross Page Posting
Cross Page Posting is a mechanism in ASP.NET that enables a Web Form to post its form data to a different page using the PostBackUrl property.
How Cross Page Posting Works
Page 1 – Source Page
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:Button ID="btnSubmit" runat="server"
Text="Submit"
PostBackUrl="~/Result.aspx" />
✔ The PostBackUrl specifies the target page.
Page 2 – Target Page
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
TextBox txtName =
(TextBox)PreviousPage.FindControl("txtName");
if (txtName != null)
{
string name = txtName.Text;
}
}
}
✔ PreviousPage gives access to the source page
✔ FindControl() fetches values from the previous page
Using @PreviousPageType (Strongly Typed – Recommended)
Page 2 (Result.aspx)
<%@ PreviousPageType VirtualPath="~/Default.aspx" %>
protected void Page_Load(object sender, EventArgs e)
{
string name = PreviousPage.txtName.Text;
}
✔ Type-safe
✔ Cleaner code
✔ Better performance
Difference: PostBack vs Cross Page Posting
| Feature | PostBack | Cross Page Posting |
|---|---|---|
| Target page | Same page | Different page |
| Property used | Default behavior | PostBackUrl |
| State handling | ViewState | PreviousPage |
| Common use | Validation | Multi-page forms |
When to Use Cross Page Posting
- ✔ Multi-step forms
- ✔ Wizard-style pages
- ✔ Simple data transfer between pages
- ✔ Avoiding Session usage
Limitations
- ❌ Only works with ASP.NET Web Forms
- ❌ Not recommended for large data transfer
- ❌ Not supported in ASP.NET MVC / Core
Interview Tip
Cross Page Posting is an ASP.NET Web Forms feature that uses the PostBackUrl property to submit form data to another page, accessible via the PreviousPage object.



.png)

