How does javascript identify controls on asp.net pages?

Discussion in 'ASP .Net' started by COHENMARVIN@lycos.com, May 6, 2008.

  1. Guest

    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
    , May 6, 2008
    #1
    1. Advertising

  2. darrel Guest

    > 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
    darrel, May 6, 2008
    #2
    1. Advertising

  3. darrel Guest

    > 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
    darrel, May 6, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manish
    Replies:
    1
    Views:
    632
    Steve C. Orr [MVP, MCSD]
    Nov 17, 2003
  2. KK
    Replies:
    2
    Views:
    381
    Hermit Dave
    Jan 25, 2004
  3. Nathan Sokalski
    Replies:
    5
    Views:
    983
    Gaurav Vaish \(www.Edujini-Labs.com\)
    Jan 10, 2007
  4. Nathan Sokalski
    Replies:
    4
    Views:
    265
    Nathan Sokalski
    Dec 21, 2006
  5. Nathan Sokalski
    Replies:
    4
    Views:
    303
    Nathan Sokalski
    Dec 21, 2006
Loading...

Share This Page