asp中的用户控制客户端ID [英] User Control Client id in asp

查看:105
本文介绍了asp中的用户控制客户端ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户控件包含一个文本框和一个按钮。在文本框中双击我想执行一些代码隐藏功能,当我双击文本框时,我使用javascript调用Button_Click事件





I have a user control contains a textbox and a button. In the textbox double click I want to execute some codebehind function for that ,I am using javascript to call Button_Click event when I am double click On the textbox


<asp:TextBox ID="txtBox" runat="server" Height="21px" Width="175px"  AutoPostBack="true" OnTextChanged="txtBox_TextChanged1"

        CausesValidation="false" Ondblclick="onTxtDoubleClick();" ClientIDMode="Static" ></asp:TextBox>



< br $>








<script type="text/javascript">
     function onTxtDoubleClick() {
         debugger;

      var x = document.getElementById("'<%= Button1.ClientID %>'");
     if (x) x.click(); else alert(x); }
    </script>











当我在我的页面上使用此用户控件时,如何获取Button1.ClientID?






When I am using this user control on my pages , How can I get Button1.ClientID ?

推荐答案

您也可以在Aspx页面中使用当前的javascript函数。此外,您可以使用以下链接找到答案:

http://stackoverflow.com/questions/2500001/get-clientid-in-user-control-from-external-javascript-file [ ^ ]



此外,您可以使用隐藏的输入类型或隐藏的ASP.net控件并为其设置ID并将其值设置为按钮的值。然后你可以在你的aspx页面中获得隐藏的控件值。这种方式更有意义。
You can use your current javascript function in Aspx page too.Additionally, you can use the below link to find your answer :
http://stackoverflow.com/questions/2500001/get-clientid-in-user-control-from-external-javascript-file[^]

Moreover, you can use a hidden input type or Hidden ASP.net control and set an id for it and set its value as the button's value. then you can get the hidden controls value in your aspx page. This way makes sense more.


这篇关于asp中的用户控制客户端ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆