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. Retrieve textbox value while using master page concept

Retrieve textbox value while using master page concept

Scheduled Pinned Locked Moved ASP.NET
javascripthtml
9 Posts 3 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
    jebin k
    wrote on last edited by
    #1

    Hi, I am using master page and i inherited a aspx page and wrote html code inside asp:Content. I wrote a javascript code to get a textbox value for validation document.getElementById("txt_Amount").value, but i could not retrieve the value. Can any one say what i am doing wrong.

    N C 2 Replies Last reply
    0
    • J jebin k

      Hi, I am using master page and i inherited a aspx page and wrote html code inside asp:Content. I wrote a javascript code to get a textbox value for validation document.getElementById("txt_Amount").value, but i could not retrieve the value. Can any one say what i am doing wrong.

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Where is your textbox ? in master page or content page ? Take view source of the page and check provided textbox name is correct.


      My Website | Ask smart questions

      J 1 Reply Last reply
      0
      • J jebin k

        Hi, I am using master page and i inherited a aspx page and wrote html code inside asp:Content. I wrote a javascript code to get a textbox value for validation document.getElementById("txt_Amount").value, but i could not retrieve the value. Can any one say what i am doing wrong.

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Almost certainly you do not have a control called txt_Amount. That may be the ID on the server, but a more complex name is generated on the client. The way to access it is to insert script along the lines of: var txtAmountId = '<%=txt_Amount.ClientID%>'; in your ASPX, and then do document.getElementById(txtAmountId) I'd still regard it as poor form to tack the .value on the end without first checking if the call returned something. The quick way here is to look at your page source to see what the Id is, then you'd see where the problem lies. Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at

        1 Reply Last reply
        0
        • N N a v a n e e t h

          Where is your textbox ? in master page or content page ? Take view source of the page and check provided textbox name is correct.


          My Website | Ask smart questions

          J Offline
          J Offline
          jebin k
          wrote on last edited by
          #4

          Textbox is in content page only, i tried this code too but not working. I saw view source i noticed the name change so i took and tried with that name. function check_user() { var str = document.getElementById('ctl00_ContentPlaceHolder1_txtUsername').value; }

          C N 2 Replies Last reply
          0
          • J jebin k

            Textbox is in content page only, i tried this code too but not working. I saw view source i noticed the name change so i took and tried with that name. function check_user() { var str = document.getElementById('ctl00_ContentPlaceHolder1_txtUsername').value; }

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Did you read my reply ?

            Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            J 1 Reply Last reply
            0
            • C Christian Graus

              Did you read my reply ?

              Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

              J Offline
              J Offline
              jebin k
              wrote on last edited by
              #6

              This is how i have declared my textbox asp:TextBox ID="txtUsername" runat="server" CssClass="textBox" Width="200px" -- modified at 6:41 Thursday 25th October, 2007

              C 1 Reply Last reply
              0
              • J jebin k

                Textbox is in content page only, i tried this code too but not working. I saw view source i noticed the name change so i took and tried with that name. function check_user() { var str = document.getElementById('ctl00_ContentPlaceHolder1_txtUsername').value; }

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                So is it working ? Christian's suggestion is the good one than this


                My Website | Ask smart questions

                J 1 Reply Last reply
                0
                • J jebin k

                  This is how i have declared my textbox asp:TextBox ID="txtUsername" runat="server" CssClass="textBox" Width="200px" -- modified at 6:41 Thursday 25th October, 2007

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  OK, I take that to mean you didn't read my reply. The name of your textbox is irrelevant, my solution will work whatever you call it.

                  Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

                  1 Reply Last reply
                  0
                  • N N a v a n e e t h

                    So is it working ? Christian's suggestion is the good one than this


                    My Website | Ask smart questions

                    J Offline
                    J Offline
                    jebin k
                    wrote on last edited by
                    #9

                    yes it working, 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