<CO*********@lycos.comwrote in message
news:69**********************************@x41g2000 hsb.googlegroups.com...
I'd like a javascript routine to calculate totals of some column in a
table. But the table is in a asp.net page, and when I do a 'view
source', I see that the names of the controls are not what I expect.
Where can I get info on using javascript with asp.net textbox fields?
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