日期:2014-05-18  浏览次数:20441 次

ASP.NET语法问题,问了再问
在A.ASPX页面:有一个TextBox1和 <a> 
有如下语句: <a href="B.aspx?ID=TextBox1.Text">跳转到B.ASPX页面 </a> 
该语句ID=TextBox1.Text出是错误的, 
我问的是ID=TextBox1.Text这里该怎么写?
注意:A.ASPX在frameset中!!!!!!!所以必须有这个Target='_top'才行!
____________________目前得到的解答都不行:
1,
Response.Redirect("B.aspx?ID=" + Server.URLEncode(TextBox1.Text)); 
当然可以实现跳转,但是没有Target='_top'效果, 
2, 
<a href="B.aspx?ID= <%=TextBox1.Text%>" Target='_top'>跳转到B.ASPX页面 </a> 
跳转正常,但不能传TextBox1.Text值到B.aspx页面.

------解决方案--------------------
C# code

<a href="B.aspx?ID= "<%=TextBox1.Text%> + " Target='_top'>" 跳转到B.ASPX页面 </a>

------解决方案--------------------
<script>
function goUrl()
{
var id=document.getElementById("TextBox1");
window.open("b.aspx?ID="+escape(id),"_top");
}
</script>
<a href='javascript:goUrl()'>Test</a>
------解决方案--------------------
HTML code

    <title>无标题页</title>
    <script type="text/javascript">
    function goUrl() 
  { 
      var id=document.getElementById("TextBox1").value; 
      this.location="b.aspx?ID="+escape(id)+"Target='_top'";
  } 
  </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <a href="javascript:goUrl()"> 跳转到B.ASPX页面 </a> 
        <asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox></div>
    </form>
</body>
</html>