我主要用了3种传值办法,我要将我需要的值放在一个文本框text里
<a href>,<asp:HyperLink>,<asp:LinkButton>
第一种 <a href="页面?id="+后面如何加这个文本框呢?>,我用<%=document.getElementById("TextBox1").value%>这样不对
第二种 <asp:HyperLink>
aspx
<asp:HyperLink ID="HyperLink1" runat="server" Style="z-index: 152; left: 311px; position: absolute;
        top: 205px" >HyperLink</asp:HyperLink>
cs
this.HyperLink1.NavigateUrl = "Message.aspx?par=" + this.TextBox1.Text;
跳传的页面cs
protected void Page_Load(object sender, EventArgs e)
    {
        this.nameTextBox1.Text = string.Format("{0}", Request.QueryString["par"].ToString());
    }
可是接不到传过来par的值 
第三种 <asp:LinkButton>
cs
url = "Message.aspx?par=" + this.TextBox1.Text;
Response.Write("<script>window.open('" + url + "');</script>");
原来的页面刷新了,我不想刷新该怎么办?
还请高手帮忙解决一下以上3个问题,成功解决立即给分。

解决方案 »

  1.   

    第一个,搞成 <a href="javascript:window.location='页面?id='+document.getElementById(<%=TextBox1.ClientID%>').value;">xxxx</a>
    第二个,this.HyperLink1.NavigateUrl = "Message.aspx?par=" + this.TextBox1.Text; 
    你写的位置不对,估计写在了page load里,用hyperlink不太好处理,不建议用。它主要处理不是从界面获取的数据。如果是需要动态从ui取值,请用LinkButton
    第三个,这是asp.net的机制决定的,要不刷新,请使用AJAX等方式。或者采用第一种方式
      

  2.   

    第一种错在这里<%=document.getElementById("TextBox1").value%> textbox1是服务器端控件要用JS获其值需这样写 <%=document.getElementById("<%=TextBox1.ClientID%>").value%>第二种看起来貌似没什么错  你可以把this.nameTextBox1.Text = string.Format("{0}", Request.QueryString["par"].ToString()); 
    这个改成这样试看this.nameTextBox1.Text = Request.QueryString["par"].ToString(); 第三种 要想不刷新不能因为服务器控件最大的特点就是要回传 所以不刷新不可能 
    要不刷新采用第一种JS  onclick="javascrip:window.location.href('xxx.aspx?id=xxx')"
      

  3.   

    漏了引号
    <a href="javascript:window.location='页面?id='+document.getElementById('<%=TextBox1.ClientID%>').value;">xxxx </a> 
      

  4.   

    楼上几位说我小弟我看过了,ok正解,可是那些是在本页面刷新的新页面,我加上了target="_blank" 想从原来的页面上再弹出一个新页,可是出了问题,这是怎么回事?
      

  5.   

    <a href="javascript:window.location='Message.aspx?par='+document.getElementById('TextBox1').value" style="z-index: 150; cursor:hand;
                left: 294px; position: absolute; top: 134px;" target="_blank">33333333333</a>
      

  6.   

    js的方式是修改当前页面,你要弹新窗,首先不需要加target="_blank"
    第二改成
    <a href="javascript:window.open('Message.aspx?par='+document.getElementById('<%=TextBox1.ClientID%>').value)" style="z-index: 150; cursor:hand;left: 294px; position: absolute; top: 134px;">33333333333 </a>
      

  7.   

    <%@ Page ValidateRequest="false" Language="C#" AutoEventWireup="true" CodeFile="Background.aspx.cs" Inherits="Background" %>
    <!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 runat="server">
    <a href="javascript:window.open('Message.aspx?par='+document.getElementById(' <%=TextBox1.ClientID%>').value)" style="z-index: 150; cursor:hand;left: 294px; position: absolute; top: 134px;">33333333333 </a>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </form>
    </body>
    </html>这样运行是有错误的!!!!当我改成下面这样的时候
    <a href="javascript:window.open('Message.aspx?par='+document.getElementById('TextBox1').value)" style="z-index: 150; cursor:hand;left: 294px; position: absolute; top: 134px;">33333333333 </a>
    弹出新页面了,可是原来的页面留下了[objest],用js不是不应该刷新吗?
      

  8.   

    这样貌似不可以吧 href里面只能跟页面地址 怎么能跟一个JS函数?我也没测只是猜哈貌似应该这样吧
    <a onclick="javascript:window.open('Message.aspx?par='+document.getElementById(' <%=TextBox1.ClientID%>').value)">xxx</a>
      

  9.   

    href里写js是可以的.
    如果用onclick,那么需要再加一个href="#",否则连接不会显示出连接的样子