首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

点击button后,button的Enabled属性变为false,并且执行Button1_Click方法,该怎么处理

2012-01-06 
点击button后,button的Enabled属性变为false,并且执行Button1_Click方法前面的button的Enabled属性变为fal

点击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);
}

热点排行