Search code examples
asp.netclient-sideasp.net-controlsclientid

Set ClientID in asp.net


Is it possible to set the ClientID of any asp.net server control? How can I do this?


Solution

  • The good news is that in VS 2010 .Net 4, you'll have complete control over Client IDs!

    Still for the current versions of .Net, you can make due. I assume you need the ID for JavaScript. If so, just get the ID like so:

    <script type="text/javascript">
        var myTextBox = $('#<%=TextBox1.ClientID%>');
    </script>