需要传递参数的页面:
public
partial
class
Page_One : PageBase
... {
protected void Page_Load(object sender, EventArgs e)
...{
// 得到当前虚拟目录
URL = Request.Path;
}
protected void Button1_Click(object sender, EventArgs e)
...{
// 跳转到另一个页面
Server.Transfer("Page_Two.aspx");
}
}
... {
protected void Page_Load(object sender, EventArgs e)
...{
// 得到当前虚拟目录
URL = Request.Path;
}
protected void Button1_Click(object sender, EventArgs e)
...{
// 跳转到另一个页面
Server.Transfer("Page_Two.aspx");
}
}
接收前一窗体的页面:
public
partial
class
Page_Two :PageBase
... {
public PageBase _objPage;
protected void Page_Load(object sender, EventArgs e)
...{
if (!IsPostBack)
...{
_objPage = Context.Handler as Page_One;
Label1.Text = _objPage.URL;
}
}
}
... {
public PageBase _objPage;
protected void Page_Load(object sender, EventArgs e)
...{
if (!IsPostBack)
...{
_objPage = Context.Handler as Page_One;
Label1.Text = _objPage.URL;
}
}
}
两个页面继承的基类:
public
class
PageBase : System.Web.UI.Page
... {
private string _URL;
public string URL
...{
get ...{ return _URL; }
set ...{ _URL = value; }
}
public PageBase()
...{
}
}
... {
private string _URL;
public string URL
...{
get ...{ return _URL; }
set ...{ _URL = value; }
}
public PageBase()
...{
}
}