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. How to disable a asp:TextBox with javascript???

How to disable a asp:TextBox with javascript???

Scheduled Pinned Locked Moved ASP.NET
javascriptcsharpjavaasp-nettutorial
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.
  • B Offline
    B Offline
    BoySetsFire
    wrote on last edited by
    #1

    Hi, js + asp.net drive me crazy!!! i want to disabel / enabel a asp:Textbox via java... but, it doesent work :-( sampel: <!-- function make() { document.GetElementById('ctl00_MainPlaceHolder1_TextBox1').disabled = true; // desen´t working document.GetElementById('ctl00_MainPlaceHolder1_TextBox1').enabled = false; document.GetElementById('TextBox1').disabled = true; // Element not exist ... } //--> >input id="myCB" type="checkbox" onclivk="make()"... <asp:TextBox ID="TextBox1" ... what make I wrong????? thx</x-turndown>

    N A P 3 Replies Last reply
    0
    • B BoySetsFire

      Hi, js + asp.net drive me crazy!!! i want to disabel / enabel a asp:Textbox via java... but, it doesent work :-( sampel: <!-- function make() { document.GetElementById('ctl00_MainPlaceHolder1_TextBox1').disabled = true; // desen´t working document.GetElementById('ctl00_MainPlaceHolder1_TextBox1').enabled = false; document.GetElementById('TextBox1').disabled = true; // Element not exist ... } //--> >input id="myCB" type="checkbox" onclivk="make()"... <asp:TextBox ID="TextBox1" ... what make I wrong????? thx</x-turndown>

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      I would consider using JQuery, http://jquery.com/[^]


      I know the language. I've read a book. - _Madmatt

      1 Reply Last reply
      0
      • B BoySetsFire

        Hi, js + asp.net drive me crazy!!! i want to disabel / enabel a asp:Textbox via java... but, it doesent work :-( sampel: <!-- function make() { document.GetElementById('ctl00_MainPlaceHolder1_TextBox1').disabled = true; // desen´t working document.GetElementById('ctl00_MainPlaceHolder1_TextBox1').enabled = false; document.GetElementById('TextBox1').disabled = true; // Element not exist ... } //--> >input id="myCB" type="checkbox" onclivk="make()"... <asp:TextBox ID="TextBox1" ... what make I wrong????? thx</x-turndown>

        A Offline
        A Offline
        Abhishek Sur
        wrote on last edited by
        #3

        document.GetElementById('ctl00_MainPlaceHolder1_TextBox1') should be document.getElementById('ctl00_MainPlaceHolder1_TextBox1') The getElementById starts with small letter. This might be your problem. use disabled = true / false; Cheers.

        Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


        My Latest Articles-->** Windows7 API Code Pack
        Simplify Code Using NDepend
        Basics of Bing Search API using .NET

        B 1 Reply Last reply
        0
        • A Abhishek Sur

          document.GetElementById('ctl00_MainPlaceHolder1_TextBox1') should be document.getElementById('ctl00_MainPlaceHolder1_TextBox1') The getElementById starts with small letter. This might be your problem. use disabled = true / false; Cheers.

          Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


          My Latest Articles-->** Windows7 API Code Pack
          Simplify Code Using NDepend
          Basics of Bing Search API using .NET

          B Offline
          B Offline
          BoySetsFire
          wrote on last edited by
          #4

          thanks for the answers... but it not a syntax problem... in my question is a write error... sorry... this is the right source code: function enableField() { alert('sdf'); document.getElementById('ctl00_MainPlaceHolder1_TextBox1').disabled = false; } hmmm..... i dont know.... f*** js

          1 Reply Last reply
          0
          • B BoySetsFire

            Hi, js + asp.net drive me crazy!!! i want to disabel / enabel a asp:Textbox via java... but, it doesent work :-( sampel: <!-- function make() { document.GetElementById('ctl00_MainPlaceHolder1_TextBox1').disabled = true; // desen´t working document.GetElementById('ctl00_MainPlaceHolder1_TextBox1').enabled = false; document.GetElementById('TextBox1').disabled = true; // Element not exist ... } //--> >input id="myCB" type="checkbox" onclivk="make()"... <asp:TextBox ID="TextBox1" ... what make I wrong????? thx</x-turndown>

            P Offline
            P Offline
            Pranay Rana
            wrote on last edited by
            #5

            i think you should also try document.form1.txt1.readOnly=true; hope this will work for you

            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