一、测试代码:
1、aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Untitled Page</title>
<script type="text/javascript">//让控件隐藏
function disableObject(obj)
{
obj.disabled = true;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" id="btn_html" value="btn_html" runat="server" onclick="disableObject(this);" onserverclick="btn_html_serverclick" />
<br />
<asp:Button ID="btn_standard" Text="btn_standard" runat="server" OnClientClick="disableObject(this);" OnClick="btn_standard_Click" />
</div>
</form>
</body>
</html>
2、cs:
protected void btn_html_serverclick(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Response.Write("actions of btn_html_serverclick");
}
protected void btn_standard_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
Response.Write("actions of btn_standard");
}
备注:以上代码中“System.Threading.Thread.Sleep(3000);”的用意是为了避免按钮事件的执行时间太短、页面刷新太快时用脚本修改的按钮状态无法体现。
Kyle