How to use ASP.Net control in Javascript

Let’s say you have a textbox (ASP.Net control) named:
To be able to use the ID in your Javascript functions, you can do something like this:
var txtbox = document.getElementById(‘<%=txtFirstName.ClientID%>’);

Then, you can use the variable ‘txtBox’ throughout your Javascript function, with the normal Javascript attributes (txtbox.value, txtbox.disabled, etc)

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>