跨页传递的基础是一个叫做PostBackUrl 的属性。
例:
CrossPage1.aspx
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”CrossPage1.aspx.cs” Inherits=”CrossPage1%>
<head runat=”server”>
<title>CrossPage1</title>
<form id=”form1” runat=”server”>
<div>
<asp:TextBox runat=”server” ID=”textFirstName”/>
<asp:Button runat=”server” ID”cmdSubmit” PostBackUrl=”CrossPage2.aspx” Text=”Submit”/>
</div>
</form>
CrossPage2.aspx
Pubic partial class CrossPage2:System.Web.UI.Page
{
Protected void Page_Load(object sender,EventArgs e)
{
If(PreviousPage!=null)
{
lblInfo.Text=”you came from a page titled”+PreviousPage.Header.Title;
}
}
}
获取多少值:
Protected void Page_load(object sender ,EventArgs e)
{
If(PreviousPage!=null)
{
CrossPage1 prePage=PreviousPage as CrossPage1;
If(prevPage!=null)
{
//
}
}
转载于:https://www.cnblogs.com/dugoogle/archive/2007/09/17/895806.html