<asp:Button ID="Button3" runat="server" Text="打分" OnClientClick="document.getElementById('ifr').src='linkhandler.ashx?ids=<%=this.txtID.Text.Trim() %>&str=<%=this.DropDownList2.SelectedValue.Trim() %>&xpath=<%=this.txtXPath.Text.Trim() %>&url=<%=this.txtUrl.Text.Trim() %>&txtid=<%=this.txtID.Text.Trim() %>';return false;"/>这样的一个链接,获取不到这些参数,该如何改<%=this.txtID.Text.Trim() %>

解决方案 »

  1.   

    document.getElementById('ifr')这个你都会,后面何以又不懂了呢?
      

  2.   

    我想ids=<%=this.txtID.Text.Trim() %>&str=<%=this.DropDownList2.SelectedValue.Trim() %>&这样弄
      

  3.   

    <%=this.txtID.Text.Trim() %> 哪里能这么获得?
      

  4.   

    $("#<%=txtID.ClientID %>").val() ?
      

  5.   

    你这是jquery的写法,还不知道对不对。
      

  6.   

    语法错误 OnClientClick="document.getElementById('ifr').src='linkhandler.ashx?ids=$('#<%=txtID.ClientID %>').val()';
      

  7.   

    你前面都会document.getElementById('ifr')这样写,后面获取也一样document呀,非要找不自在?
      

  8.   

    本帖最后由 Sandy945 于 2011-12-05 17:10:00 编辑
      

  9.   

    ids=<%=this.txtID.Text.Trim() %>

    txtid=<%=this.txtID.Text.Trim() %>这两个参数取值是特意一样的?
      

  10.   

    阿非,这个的值貌似没有获得到var str=document.getElementById('<%=DropDownList2.ClientID%>').value;
      

  11.   

    阿非,这个的值没有得到var str=document.getElementById('<%=DropDownList2.ClientID%>').value;
      

  12.   

    其实我是想说DropDownList2那样取值取不到
      

  13.   

    你贴下生成的html 代码和下拉框有关的 
      

  14.   

        <script> 
    var setIFRSrc=function(){
         var ids=document.getElementById('txtID').value;
         var str=document.getElementById('DropDownList2').value; //document.getElementById('DropDownList2').value;
         var xpath=document.getElementById('txtXPath').value;
         var url=document.getElementById('txtUrl').value;
         document.getElementById('ifr').src='linkhandler.ashx?ids='+ids+'&str'+str+'&xpath='+xpath+'&url='+url;
    }
    </script>
    </head>
    <body>
        <form name="form1" method="post" action="LinkForAjax.aspx" id="form1">
    <div>
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTIxNDc0ODMwNjEPZBYCAgMPZBYCAgcPEA8WAh4LXyFEYXRhQm91bmRnZA8WAWYWARAFFGh0dHA6Ly9iai5nYW5qaS5jb20vBRRodHRwOi8vYmouZ2FuamkuY29tL2dkZGT9vchLPS+eHLIgkCl0w0DMdaSW1Q==" />
    </div>
     
    <div>
     
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCgKL35aIAQKa+/bVAgKF2fXbAwKgwpPxDQLhrOCkDQLCn9KrDQL5qs3CCwKs+5bqDwKqiNHJBAKqos2AB6w/WkwBg6vxE44GkfbBFaFCCFD5" />
    </div>
        <div>
            <table>
                <tr>
                    <th colspan="2">
                        抓取友情链接
                    </th>
                </tr>
                <tr>
                    <td class="style1">
                        url:
                    </td>
                    <td>
                        <input name="txtUrl" type="text" value="http://bj.ganji.com/" id="txtUrl" style="width:206px;" />
                    &nbsp;&nbsp;&nbsp;
                        <input type="submit" name="Button4" value="添加" id="Button4" />
    &nbsp;&nbsp;
                        <input type="submit" name="Button5" value="删除" id="Button5" />
                        &nbsp;&nbsp;&nbsp;
                        <select name="DropDownList1" id="DropDownList1">
    <option value="http://bj.ganji.com/">http://bj.ganji.com/</option>
     
    </select>
                    </td>
      

  15.   

    <select name="DropDownList1" id="DropDownList1">
     var str=document.getElementById('DropDownList2').value;
      

  16.   

    你之前页面有两个DropDownList么?
      

  17.   

    是有两个,但是还是取不到 var str=document.getElementById('DropDownList2').value; 
      

  18.   

    我用alert输出了一下,是可以获取到的,但是传到handler中就是未将对象引用设置到实例
      

  19.   

    <%=this.txtID.Text.Trim() %>这种写法是绝对取不到修改好的值的。要明白前端跟后台的区别。只能用js