Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. getting the value of an asp element with javascript

getting the value of an asp element with javascript

Scheduled Pinned Locked Moved ASP.NET
javascriptquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    johland
    wrote on last edited by
    #1

    hi is it possible to get an ASP element with javascript? I'm trying to get the text of an asp textbox (or the value of input type text) that is nested within an ASP TemplateField . thanks in advance j

    P V B 3 Replies Last reply
    0
    • J johland

      hi is it possible to get an ASP element with javascript? I'm trying to get the text of an asp textbox (or the value of input type text) that is nested within an ASP TemplateField . thanks in advance j

      P Offline
      P Offline
      Parwej Ahamad
      wrote on last edited by
      #2

      Yes , First find the control bby control id like :

      var obj=document.getElementById('Controlid').vlaue;

      Parwej Ahamad g.parwez@gmail.com

      J 1 Reply Last reply
      0
      • J johland

        hi is it possible to get an ASP element with javascript? I'm trying to get the text of an asp textbox (or the value of input type text) that is nested within an ASP TemplateField . thanks in advance j

        V Offline
        V Offline
        vaseeem
        wrote on last edited by
        #3

        You can use document.getElementById(fieldID).

        Errors are like Mini Skirts, shorter they get, more revealing they become.

        J 1 Reply Last reply
        0
        • P Parwej Ahamad

          Yes , First find the control bby control id like :

          var obj=document.getElementById('Controlid').vlaue;

          Parwej Ahamad g.parwez@gmail.com

          J Offline
          J Offline
          johland
          wrote on last edited by
          #4

          but how can i predict the control id as ASP elements don't have a predetermined id? (i can't use the 'ID' attribute as opposed to the HTML id attribute)

          1 Reply Last reply
          0
          • V vaseeem

            You can use document.getElementById(fieldID).

            Errors are like Mini Skirts, shorter they get, more revealing they become.

            J Offline
            J Offline
            johland
            wrote on last edited by
            #5

            thanks but please see my reply to Parwej above.. j

            1 Reply Last reply
            0
            • J johland

              hi is it possible to get an ASP element with javascript? I'm trying to get the text of an asp textbox (or the value of input type text) that is nested within an ASP TemplateField . thanks in advance j

              B Offline
              B Offline
              balaji t
              wrote on last edited by
              #6

              hi dude, suppose the textbox id is txtname give like this var name = document.getelementbyid(txtname).value; here txtname-->controlid as mentioned by parwej u got it now

              T.Balaji

              J 1 Reply Last reply
              0
              • B balaji t

                hi dude, suppose the textbox id is txtname give like this var name = document.getelementbyid(txtname).value; here txtname-->controlid as mentioned by parwej u got it now

                T.Balaji

                J Offline
                J Offline
                johland
                wrote on last edited by
                #7

                sorry if i'm missing something or wasn't clear enough : I need the id for an ASP control that within a GridView (as mentioned - nested within asp:TemplateField) so for example if my code is: <asp:TextBox runat="server" ID="txtName">> after rendering the TextBox id will be something like: "ctl00_ContentPlaceHolder1_gridView_ctl12_txtName" thanks

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups