If you have an <asp:TextBox /> control called MyTextBox, you refer to it
server-side just with its name e.g.
MyTextBox.Text = "Hello";
However, as you've discovered, this almost certainly isn't what ASP.NET
calls the control by the time it's rendered to the client browser.
Thankfully, this is easily solved. Simply "inject" the name of the control
into your JavaScript dynamically by means of its ClientID property, e.g.
<script type="text/javascript">
var myTextBox = document.getElementById('<%=MyTextBox.ClientID%>');
</script>
--
Mark Rae
ASP.NET MVP
http://www.markrae.net
Javascript has no concept of ASP.net controls as they are server-side
concepts.
Javascript, being client side, simply sees the HTML that is produced by the
server and delivered to the web browser.
> Where can I get info on using javascript with asp.net textbox fields?
Javascript just see the INPUT field. You'd get the info from the INPUT field
via javascript and the DOM.
Typically you'd use something like getElementByID('IDofYourInputField).value
-Darrel
> Typically you'd use something like
> getElementByID('IDofYourInputField).value
Typically, this won't work because chances are you'll have no way of knowing
what the name of the DOM element is by the time it's been rendered to the
client browser - see my earlier reply...
I've found that it's usually the ID of the usercontrol/webcontrol
However, to be accurate, you use the asp.net clientID propert to write the
value into the javascript:
document.getElementByID('<%=yourInputField.ClientID%>').value
(which, I just now see, you already mentioned in your other reply. ;o)
-Darrel