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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. Using JavaScript to Change Server-Side TextBox

Using JavaScript to Change Server-Side TextBox

Scheduled Pinned Locked Moved Visual Basic
javascripthelpsysadmin
5 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.
  • F Offline
    F Offline
    ftbadolato
    wrote on last edited by
    #1

    I have the following TextBox on my .aspx page. top: 632px" runat="server" Width="1px" Height="1px" ReadOnly="false">no The JavaScript from viewing the source is as follows. There is some JS above what you see here, but it is working fine. I also have a try...catch around all of this. The error that occurs is [object Error] and it occurs on the lines below when I attempt to set the value of the text box. The text box is on the page, but I am thinking it may have something to do with the runat="server" in the code above. I need that though b/c I check the field in my code-behind file as well. I need help on updating the value of this field via JavaScript. if(result == true){ document.getElementById('aspnetForm._ctl0_ContentP laceHolder1_hdnresultbox').value='yes'; }else{ document.getElementById('aspnetForm._ctl0_ContentP laceHolder1_hdnresultbox').value='no'; } return result;

    F G C 3 Replies Last reply
    0
    • F ftbadolato

      I have the following TextBox on my .aspx page. top: 632px" runat="server" Width="1px" Height="1px" ReadOnly="false">no The JavaScript from viewing the source is as follows. There is some JS above what you see here, but it is working fine. I also have a try...catch around all of this. The error that occurs is [object Error] and it occurs on the lines below when I attempt to set the value of the text box. The text box is on the page, but I am thinking it may have something to do with the runat="server" in the code above. I need that though b/c I check the field in my code-behind file as well. I need help on updating the value of this field via JavaScript. if(result == true){ document.getElementById('aspnetForm._ctl0_ContentP laceHolder1_hdnresultbox').value='yes'; }else{ document.getElementById('aspnetForm._ctl0_ContentP laceHolder1_hdnresultbox').value='no'; } return result;

      F Offline
      F Offline
      ftbadolato
      wrote on last edited by
      #2

      Sorry....textbox code did not post. no

      M 1 Reply Last reply
      0
      • F ftbadolato

        Sorry....textbox code did not post. no

        M Offline
        M Offline
        Michael Bisbjerg
        wrote on last edited by
        #3

        Well, serverside the ID of the textbox is not: "aspnetForm._ctl0_Conten...". But rather the ID itself at designtime: "hdnresultbox". Tried that?

        1 Reply Last reply
        0
        • F ftbadolato

          I have the following TextBox on my .aspx page. top: 632px" runat="server" Width="1px" Height="1px" ReadOnly="false">no The JavaScript from viewing the source is as follows. There is some JS above what you see here, but it is working fine. I also have a try...catch around all of this. The error that occurs is [object Error] and it occurs on the lines below when I attempt to set the value of the text box. The text box is on the page, but I am thinking it may have something to do with the runat="server" in the code above. I need that though b/c I check the field in my code-behind file as well. I need help on updating the value of this field via JavaScript. if(result == true){ document.getElementById('aspnetForm._ctl0_ContentP laceHolder1_hdnresultbox').value='yes'; }else{ document.getElementById('aspnetForm._ctl0_ContentP laceHolder1_hdnresultbox').value='no'; } return result;

          G Offline
          G Offline
          Guffa
          wrote on last edited by
          #4

          As I can't see the controls surrounding the TextBox, I don't know exactly what the client id will be, but aspnetForm. is definitely not part of the id.

          Despite everything, the person most likely to be fooling you next is yourself.

          1 Reply Last reply
          0
          • F ftbadolato

            I have the following TextBox on my .aspx page. top: 632px" runat="server" Width="1px" Height="1px" ReadOnly="false">no The JavaScript from viewing the source is as follows. There is some JS above what you see here, but it is working fine. I also have a try...catch around all of this. The error that occurs is [object Error] and it occurs on the lines below when I attempt to set the value of the text box. The text box is on the page, but I am thinking it may have something to do with the runat="server" in the code above. I need that though b/c I check the field in my code-behind file as well. I need help on updating the value of this field via JavaScript. if(result == true){ document.getElementById('aspnetForm._ctl0_ContentP laceHolder1_hdnresultbox').value='yes'; }else{ document.getElementById('aspnetForm._ctl0_ContentP laceHolder1_hdnresultbox').value='no'; } return result;

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

            Use the ClientID property on the server side to write the id to a variable, then it will always be right.

            Christian Graus Please read this if you don't understand the answer I've given you "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
            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