Set ClientID in asp.net

ebattulga picture ebattulga · Sep 15, 2009 · Viewed 19k times · Source

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

Answer

Michael La Voie picture Michael La Voie · Sep 15, 2009

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>