利用Response和Request实现相邻页面的数据传递。
通过 Response 对象的跳转方法设置目标 URL 的值。
Response.Redirect“~/abc.aspx?a=value1&b=value2”);
通过 Request 的 QueryString 方式读取数据。
Request.QueryString["a"]
Request.QueryString["b"]
代码不是有了,题主有什么问题吗?具体实现如下
a.aspx(访问这个页面)
<%@ Page Language="C#" %>
<script runat="server">
protected void redirec_click(object sender, EventArgs e)
{
Response.Redirect("~/abc.aspx?a=value1&b=value2");
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>页面跳转并传递参数</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Button runat="server" OnClick="redirec_click" Text="点击跳转到abc.aspx" />
</form>
</body>
</html>
abc.aspx(接收数据页面)
<%@ Page Language="C#" %>
<script runat="server">
protected string a, b;
protected void Page_Load(object sender, EventArgs e)
{
a = Request.QueryString["a"];
b = Request.QueryString["b"];
this.DataBind();//数据绑定,就是<%#%>这种数据块,也可以用asp的语法<%=a%>,省略DataBind
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>abc.aspx</title>
</head>
<body>
<h3>a参数值:<%#a %></h3>
<h3>b参数值:<%#b %></h3>
</body>
</html>
你好,
所以你的问题是什么呢? 有什么可以帮助你的呢?