




























好久没有写东西了,今天将以前给同事写的一段代码改了一下共享出来。这段代码用于实现在点击按钮后禁用它直到操作完成。有更好的方法大家可以讨论!
<%@ Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server">
protected void Page_Load (object sender, EventArgs e)
{
btn.Attributes.Add ("onclick",
Page.GetPostBackEventReference (btn, "") +
";this.value='Submitting
';this.disabled = true;");
lbtn.Attributes.Add ("onclick",
"this.innerText='Submitting
';this.disabled = true;");
ibtn.Attributes.Add ("onclick",
Page.GetPostBackEventReference (ibtn, "") +
";this.alt='Submitting
';this.disabled = true;");//
// ASP.NET 2.0 above
//
//btn.Attributes.Add ("onclick",
// ClientScript.GetPostBackEventReference (btn, "") +
// ";this.value='Submitting';this.disabled = true;");
//lbtn.Attributes.Add ("onclick",
// "this.innerText='Submitting';this.disabled = true;");
//ibtn.Attributes.Add ("onclick",
// ClientScript.GetPostBackEventReference (ibtn, "") +
// ";this.alt='Submitting';this.disabled = true;");
//
// OR
//
//btn.OnClientClick =
// ClientScript.GetPostBackEventReference (btn, "") +
// ";this.value='Submitting
';this.disabled = true;";
//lbtn.OnClientClick = "this.innerText='Submitting
';this.disabled = true;";
//ibtn.OnClientClick = ClientScript.GetPostBackEventReference (ibtn, "") +
// ";this.alt='Submitting
';this.disabled = true;";
}
protected void btn_Click (object sender, EventArgs e)
{
System.Threading.Thread.Sleep (2000);
Label1.Text = DateTime.Now.ToString ();
}
protected
void lbtn_Click (object sender, EventArgs e)protected
void ibtn_Click (object sender, ImageClickEventArgs e)此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。