How does javascript identify controls on asp.net pages?

  • Thread starter Thread starter COHENMARVIN
  • Start date Start date
C

COHENMARVIN

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?
Thanks,
Marv
 
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.

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, 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
 
Back
Top