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. Disable Textbox

Disable Textbox

Scheduled Pinned Locked Moved ASP.NET
javascriptsysadmintoolshelpquestion
7 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.
  • M Offline
    M Offline
    M_Menon
    wrote on last edited by
    #1

    Hi Friends, I have posted this before also. But i didnt get any replies? Is it really not possible to disable a asp TextBox on Click of asp Button? I am trying Javascript. I am able to call the script onclick of my button, but i believe i am not able to get the TextBox control and disable it. My script goes function Validate() { document.getElementById('GVRoomType_ctl07_txtNewName').diabled=true; } <asp:LinkButton ID="lbtnEdit" runat="server" OnClientClick="Validate()" CausesValidation="False" Thanks for your help.. Cheers Menon

    C A 2 Replies Last reply
    0
    • M M_Menon

      Hi Friends, I have posted this before also. But i didnt get any replies? Is it really not possible to disable a asp TextBox on Click of asp Button? I am trying Javascript. I am able to call the script onclick of my button, but i believe i am not able to get the TextBox control and disable it. My script goes function Validate() { document.getElementById('GVRoomType_ctl07_txtNewName').diabled=true; } <asp:LinkButton ID="lbtnEdit" runat="server" OnClientClick="Validate()" CausesValidation="False" Thanks for your help.. Cheers Menon

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

      If you want a control to run javascript, why make it a server control at all ? This will work, so long as you spell 'disabled' properly, and so long as the Id is right. I tend to put something like this in my ASPX '; Or you can emit the code in your code behind with RegisterClientScriptBlock calls. I put the rest of my script in a .js file. That way, I know my Id is always good. And, I make sure my code is spelled right. I use firefox and firebug to debug my javascript. Without it, you're kind of lost at sea. Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      M 1 Reply Last reply
      0
      • C Christian Graus

        If you want a control to run javascript, why make it a server control at all ? This will work, so long as you spell 'disabled' properly, and so long as the Id is right. I tend to put something like this in my ASPX '; Or you can emit the code in your code behind with RegisterClientScriptBlock calls. I put the rest of my script in a .js file. That way, I know my Id is always good. And, I make sure my code is spelled right. I use firefox and firebug to debug my javascript. Without it, you're kind of lost at sea. Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        M Offline
        M Offline
        M_Menon
        wrote on last edited by
        #3

        Thank you Christian I am using a TextBox which has Validators inside Footer Template of GridView, which i want to disable on the Click of Link Button Update. I dont know if i can do this on client side? And i believe because the txtNewName is inside the GridView i am not getting its ID. When i am using the script '; I am getting the Error txtNewName does not exists... And Thanks for the tips. I will make sure about my spellings and using Firefox to debug my Javascript. Thanks Cheers Menon

        C 1 Reply Last reply
        0
        • M M_Menon

          Hi Friends, I have posted this before also. But i didnt get any replies? Is it really not possible to disable a asp TextBox on Click of asp Button? I am trying Javascript. I am able to call the script onclick of my button, but i believe i am not able to get the TextBox control and disable it. My script goes function Validate() { document.getElementById('GVRoomType_ctl07_txtNewName').diabled=true; } <asp:LinkButton ID="lbtnEdit" runat="server" OnClientClick="Validate()" CausesValidation="False" Thanks for your help.. Cheers Menon

          A Offline
          A Offline
          Abhijit Jana
          wrote on last edited by
          #4

          Hi, This will work for You :) :) :) function Validate() { form1.Text1.disabled = true; } Please inform me if it working fine !!! i have check in my side !!!!

          Happy Programming ----- Abhijit

          M 1 Reply Last reply
          0
          • M M_Menon

            Thank you Christian I am using a TextBox which has Validators inside Footer Template of GridView, which i want to disable on the Click of Link Button Update. I dont know if i can do this on client side? And i believe because the txtNewName is inside the GridView i am not getting its ID. When i am using the script '; I am getting the Error txtNewName does not exists... And Thanks for the tips. I will make sure about my spellings and using Firefox to debug my Javascript. Thanks Cheers Menon

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

            mady1380 wrote:

            And i believe because the txtNewName is inside the GridView i am not getting its ID.

            OK, yes, that won't work. You'd have to do it within an event of the gridview control, the event that create the row with the textbox.

            mady1380 wrote:

            I am using a TextBox which has Validators inside Footer Template of GridView, which i want to disable on the Click of Link Button Update.

            Ah - you can write a custom validator which fires your other validators manually. Then, you can put the validator you want to control in a different group, and only fire it under certain conditions. This involves digging around in the .NET generated javascript, but it's quite doable.

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

            M 1 Reply Last reply
            0
            • A Abhijit Jana

              Hi, This will work for You :) :) :) function Validate() { form1.Text1.disabled = true; } Please inform me if it working fine !!! i have check in my side !!!!

              Happy Programming ----- Abhijit

              M Offline
              M Offline
              M_Menon
              wrote on last edited by
              #6

              Thank you Abhijit But its not working for me. I just want to remind you again, that the TextBox is inside the Footer Template of my GridView. Thanks Cheers Menon

              1 Reply Last reply
              0
              • C Christian Graus

                mady1380 wrote:

                And i believe because the txtNewName is inside the GridView i am not getting its ID.

                OK, yes, that won't work. You'd have to do it within an event of the gridview control, the event that create the row with the textbox.

                mady1380 wrote:

                I am using a TextBox which has Validators inside Footer Template of GridView, which i want to disable on the Click of Link Button Update.

                Ah - you can write a custom validator which fires your other validators manually. Then, you can put the validator you want to control in a different group, and only fire it under certain conditions. This involves digging around in the .NET generated javascript, but it's quite doable.

                Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                M Offline
                M Offline
                M_Menon
                wrote on last edited by
                #7

                Thank you Christian "you can write a custom validator which fires your other validators manually. Then, you can put the validator you want to control in a different group, and only fire it under certain conditions. This involves digging around in the .NET generated javascript, but it's quite doable." I believe i will try Digging around for the Custom Validations Thanks Cheers Menon

                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