如何在单击按钮时启用/禁用文本框 [英] How to enable/disable a text box on clicking a button
本文介绍了如何在单击按钮时启用/禁用文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在单击按钮时启用文本框?
首先,我将属性readonly ="true"插入文本框.
单击按钮时,应使用什么代码为文本框设置属性readonly = false
OP的其他信息从下面的非解决方案3移出
我在点击处理程序中写这个
txtID.Attributes("readonly","false")
但没有成功:/
How can I enable a text box on clicking a button?
firstly I insert the property readonly="true" to the textbox.
what code should i use to set the property readonly=false for the textbox when i click the button
OP''s additional information moved from non-solution 3 below
i write this one in the click handler
txtID.Attributes("readonly", "false")
but no success :/
推荐答案
如果您的代码正在回发,则可以在C#中将ReadOnly设置为false.如果您想在客户端执行此操作,我建议您使用jQuery,然后您就可以执行
If your code is posting back then in the C# you can set ReadOnly = false. If you want to do it on client side I would recommend using jQuery and then you can do
(" ).attr(" , false );
("#idOfTextBox").attr("disabled",false);
1)在您的代码后面添加一个点击处理程序,并将其绑定到Button控件.
2)在点击处理程序中,编写类似YourTextBox.readonly = false
的内容 3)就这样.
干杯.
看到您的答案是一个Web应用程序后,请参阅ryan的答案.
1) Add a click handler to your code behind and tie it to your Button control.
2) In the click handler, write something likeYourTextBox.readonly = false
3) That''s it.
Cheers.
After seeing your answer that this is a web app, See ryan''s answer as the way to go.
这篇关于如何在单击按钮时启用/禁用文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文