是ASP.NET 2.0么?
如果是
服务器按钮控件有个postbackurl
这个属性设为要跳转的页面的URL
然后在跳转后的页面可以得到前一个页面的控件
然后访问相关控件的属性其他还有用session,cache等等都可以
如果是
服务器按钮控件有个postbackurl
这个属性设为要跳转的页面的URL
然后在跳转后的页面可以得到前一个页面的控件
然后访问相关控件的属性其他还有用session,cache等等都可以
FirstPage.aspx
<%@ 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 UserName {
get {
return this.txtName.Text;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Postback from self. Your Name is: " + txtName.Text;
}
</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<meta content="text/JScript" http-equiv="content-script-type" />
<title>First Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h3>The Frist Page</h3>
Your Name:
<asp:TextBox ID="txtName" runat="server" />
<asp:Label ID="Label1" runat="server" EnableViewState="False" /><br />
<br />
<asp:Button ID="Button1" runat="server" Text="Postback to Same Page" OnClick="Button1_Click" /><br />
<br />
<asp:Button ID="Button2" runat="server" Text="Postback to Second Page" PostBackUrl="~/SecondPage.aspx" /><br />
</div>
</form>
</body>
</html>SecondPage.aspx
<%@ Page Language="C#" %>
<%@ PreviousPageType VirtualPath="~/FirstPage.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 = "Your Name is : " + PreviousPage.UserName;
}
</script><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Second Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h1>This is the Second Page</h1>
<p><asp:Label ID="Label1" runat="server"></asp:Label> </p>
</div>
</form>
</body>
</html>
一定注意SecondPage.aspx里红色的标记一定要有
在SecondPage.aspx.cs里取FirstPage.aspx的值:
if (Page.PreviousPage != null)
{
TextBox txtName = (TextBox)Page.PreviousPage.FindControl("txtName");
if (txtName != null)
{
Label1.Text = txtName.Text;
}
}
把查询条件都用Session保存起来,然后用的时候直接用Session就OK了
感觉用Session不爽!Session清空问题很郁闷
----------------------------
他的意思是指按钮控件的postbackurl属性.
实体序列化成字符串后进行传
传到之后进行反序列化~Result.aspx?query=querystring
有一点就是序列化后的querystring很长~
string mdname=request["mdname"];