aspnet超级链接 传递 当前页面 textbox值

时间:2024-08-17 14:06:14
一共有两个窗体、 第一个窗体A传参到窗体B  A的参数是A窗体的textbox
窗体A代码
 <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function test() {
var gysvalue = document.getElementById("txtgys").value;
var thvalue = document.getElementById("txtth").value;
document.getElementById("a").href = "DataDemo.aspx?txtgys=" + gysvalue + "&txtth=" + thvalue;
}
</script>
</head>
<body>
<table>
<tr>
<td>
供应商<asp:TextBox ID="txtgys" runat="server"></asp:TextBox>
</td>
<td>
图号<asp:TextBox ID="txtth" runat="server"></asp:TextBox>
</td>
<td>
&nbsp;</td>
</tr>
</table>
</body>
<a href="#" id="a" target="_blank" onclick ="test();"><<查询>></a>

窗体B代码

 <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br /> </div>
<div> <asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<br /> </div>
</form>
</body>
</html>

窗体B  cs 代码

  protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request.QueryString["txtgys"].ToString();
Label2.Text = Request.QueryString["txtth"].ToString(); }