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