Click here to Skip to main content
15,900,818 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


XML
<asp:TextBox ID="txtBox" runat="server" Height="21px" Width="175px"  AutoPostBack="true" OnTextChanged="txtBox_TextChanged1"
        CausesValidation="false" Ondblclick="onTxtDoubleClick();" ClientIDMode="Static" ></asp:TextBox>




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

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





When I am using this user control on my pages , How can I get Button1.ClientID ?
Posted
Comments
Dholakiya Ankit 7-Aug-13 2:46am    
is this a repost you have already added this q......

1 solution

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.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900