In ASP.NET 1.x, many friends may need to perform cross-page submission processing, that is, they can submit from page A to page B. Even different Controls have different target processing pages. Especially developers who have transferred from ASP/JSP/PHP may have this need. But unfortunately, in ASP.NET 1.x, handling such cross-page requests was very ugly and required a lot of "skills".
In ASP.NET 2.0, there was already a very reasonable solution for cross-page submission. The following is an example.
SourcePage.aspx: Please pay attention to the PostBackUrl attribute setting of Button1
<%...@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat="server">...
public string YourName
...{
get
...{
return this.TextBox1.Text;
}
}
</script>
<html xmlns=" http://www.w3.org/1999/xhtml " >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Please enter your name" Width="183px"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Submit" PostBackUrl="~/TargetPage.aspx" /></div>
</form>
</body>
</html>
TargetPage.aspx: Please pay attention to the property setting of PreviousPageType
<%...@ Page Language="C#" %>
<%...@ PreviousPageType VirtualPath="~/SourcePage.aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR /xhtml1/DTD/xhtml1-transitional.dtd ">
<script runat="server">...
protected void Page_Load(object sender, EventArgs e)
...{
this.Label1.Text = PreviousPage.YourName;
}
</script>
<html xmlns=" http://www.w3.org/1999/xhtml " >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" ></asp:Label>
</div>
</form>
</body>
</html>
OK, with such simple two attribute settings, you can easily get the cross-page submission feature. Of course, you can also make more complex settings based on your own needs, such as if each Control needs to be submitted to a different page.