Disabled = true在后面的代码中不起作用 [英] Disabled = true does not work in code behind
本文介绍了Disabled = true在后面的代码中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下内容:
I have the following:
<button id="btnSend" runat="server" alt="" CausesValidation="false" onserverclick="btnSend_Click">
<img id="imgSend" alt="" runat="server" src="~/Images/Buttons/send_ico.gif"
align="top" />
<span><b class="va">Send Message</b></span>
</button>
我想禁用.
I would like to disable.
protected void btnSend_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
btnSend.Disabled = true;
System.Threading.Thread.Sleep(2000);
}
}
这不起作用.
已修改:
我要做的就是禁用按钮,这样用户就不会单击两次.
this does not work.
Modified:
All I want to do is disable the button so it the user does not click twice.
private void InitializeComponent()
{
this.btnSend.ServerClick += new System.EventHandler(this.btnSend_Click);
}
推荐答案
我不确定甚至没有Disabled
属性.尝试将Enabled
设置为false
.
顺便说一句,如果您指的是HTML属性,则可能需要在客户端脚本中进行设置.
这是从客户端禁用按钮的示例:
I am not sure there''s even aDisabled
property. Try settingEnabled
tofalse
.
BTW if you mean the HTML attribute, you probably need to set that in client side script.
Here''s an example of disabling a button from the client-side:
<input type="button" onclick="this.disabled=1">
有标记中的怪异字符:
ö nserverclick
There''s a weird character in the markup:
önserverclick
请尝试以下方式:
Please try it this way:
protected void btnSend_Click(object sender, EventArgs e)
{
if (Page.IsValid)
{
btnSend.Attributes["disabled"] = "disabled";
System.Threading.Thread.Sleep(2000);
}
}
正如已经观察到的,ö应该是o.
干杯!
And as already observed the ö should be an o.
Cheers!
这篇关于Disabled = true在后面的代码中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文