<script type= "text/javascript ">
function send()
{
document.getElementById( "Button1 ").disabled=true;
}
</script>
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "保存 "/>
这已经有onclick事件了 不能在写一次
所以只能从后台写
this.Button1.Attributes.Add( "onclick ", "javascript:send();return false; ");
但放在哪呢?
必须是提交后把button变为灰的
------解决方案--------------------------------------------------------
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "保存 "/>
这已经有onclick事件了 不能在写一次
============
楼主,服务器端的按钮还有一个属性,OnClientClick
<asp:Button ID= "Button1 " OnClientClick= "send() "
runat= "server " OnClick= "Button1_Click " Text= "保存 "/>
------解决方案--------------------------------------------------------
同意zhulei2008(滴水浪流) 的说法,用onClientClick
------解决方案--------------------------------------------------------
// .net 2.0
<asp:Button ID= "Button1 " UseSubmitBehavior= "false " runat= "server " OnClientClick= "this.value= 'submitting ';this.disabled=true; " OnClick= "Button1_Click " Text= "Test1 " />
// .net 1.x
// .aspx
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "Test1 " />
// .apsx.cs at Page_Load
Button1.Attributes[ "onclick "] = "this.value= 'submitting ';this.disabled=true; ";