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. General Programming
  3. C / C++ / MFC
  4. How to disable a HTML Input in c#

How to disable a HTML Input in c#

Scheduled Pinned Locked Moved C / C++ / MFC
csharphtmlasp-nettutorial
2 Posts 2 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.
  • U Offline
    U Offline
    User 12161200
    wrote on last edited by
    #1

    Hi all, Tt's a HTML Input box like this.

    and for some reason, I cannot use ASP.net textbox. However, I need to disable it when a button is clicked (I tried both AUTOPOSTBACK and non-AUTOPOSTBACK button) . I tried the followings in c# but none of these works.

                Page.ClientScript.RegisterStartupScript(this.GetType(), "clientscript", "document.getElementById('testInput').readOnly = true;");
    
                Page.ClientScript.RegisterStartupScript(this.GetType(), "clientscript", "document.getElementById('testInput').disable= true;");
    

    Page.ClientScript.RegisterStartupScript(this.GetType(), "clientscript", "document.getElementById('testInput').disable= 'true';");

    ' Please advice, thanks!

    B 1 Reply Last reply
    0
    • U User 12161200

      Hi all, Tt's a HTML Input box like this.

      and for some reason, I cannot use ASP.net textbox. However, I need to disable it when a button is clicked (I tried both AUTOPOSTBACK and non-AUTOPOSTBACK button) . I tried the followings in c# but none of these works.

                  Page.ClientScript.RegisterStartupScript(this.GetType(), "clientscript", "document.getElementById('testInput').readOnly = true;");
      
                  Page.ClientScript.RegisterStartupScript(this.GetType(), "clientscript", "document.getElementById('testInput').disable= true;");
      

      Page.ClientScript.RegisterStartupScript(this.GetType(), "clientscript", "document.getElementById('testInput').disable= 'true';");

      ' Please advice, thanks!

      B Offline
      B Offline
      Bryian Tan
      wrote on last edited by
      #2

      The syntax should be "disabled" not "disable"

      document.getElementById('testInput').disabled = true;

      HTML DOM Input Text disabled Property[^] By the way, I think you should had posted this question to Web Development Discussion Boards[^] instead of "C / C++ / MFC"

      Bryian Tan

      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