How do I reference a server control in javascript?

<%=ServerControlID.ClientID%>

Yes that’s all you need . For Example suppose you have a asp.net textbox server control whose ID is “Textbox1″ . In your javascript code to get the value of the control you will use something like this

var myValue= document.getElementById('<%=TextBox1.ClientID%>').value;

No related posts.

2 Responses to “How do I reference a server control in javascript?”

  1. Very useful, quick tip.

  2. Mahendra Ghedia on October 27th, 2008 at 4:16 pm

    Great help dude…!!

Leave a Reply