日期:2014-05-18  浏览次数:20373 次

点击button后,button的Enabled属性变为false,并且执行Button1_Click方法
前面的button的Enabled属性变为false只要在onclick加上this.disabled   =   true就可以了。

但问题是一般情况下这里应该是Button1_Click,onclick= "this.disabled   =   true;Button1_Click "就不行了,如何让onclick执行2个操作?

------解决方案--------------------
Button1_Click函数里去disabled
------解决方案--------------------
Button1_Click;this.disabled = true
------解决方案--------------------
直接在Page_Load事件里加入:

//针对有进行表单验证的(即HTML源代码里Button1.onclick= "__DoPostBack(...) "的
Button1.Attributes.Add( "onclick ", "this.disabled=true;return true; ") ;

//针对没有表单验证的直接提交
Button1.Attributes.Add( "onclick ", "this.disabled=true;document.getElementById( ' "+
this.Form.ClientID+ " ').submit(); ");
------解决方案--------------------
顶你个肺只是那一小会为FALSE而已
------解决方案--------------------
假如你在 asp.net 2.0 下,那么 Button 默认使用 input type=submit, 你可以通过 UseSubmitBehavior= "false " 改成呈现为 input type=button 就可以了

测试:

<asp:Button ID= "Button1 " UseSubmitBehavior= "false " runat= "server " OnClientClick= "this.disabled=true; " OnClick= "Button1_Click " Text= "Button " />

protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(1000 * 5);
}