How does javascript identify controls on asp.net pages?

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
 
D

darrel

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
 
D

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top