惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

WordPress大学
WordPress大学
V
Visual Studio Blog
P
Privacy International News Feed
月光博客
月光博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
L
Lohrmann on Cybersecurity
N
News and Events Feed by Topic
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Apple Machine Learning Research
Apple Machine Learning Research
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
T
Threatpost
宝玉的分享
宝玉的分享
The Last Watchdog
The Last Watchdog
小众软件
小众软件
L
LINUX DO - 最新话题
C
Cisco Blogs
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
酷 壳 – CoolShell
酷 壳 – CoolShell
www.infosecurity-magazine.com
www.infosecurity-magazine.com
雷峰网
雷峰网
G
GRAHAM CLULEY
有赞技术团队
有赞技术团队
Know Your Adversary
Know Your Adversary
博客园 - 叶小钗
罗磊的独立博客
V
V2EX
博客园 - Franky
P
Proofpoint News Feed
SecWiki News
SecWiki News
腾讯CDC
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
博客园 - 三生石上(FineUI控件)
S
Secure Thoughts
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Google DeepMind News
Google DeepMind News
Attack and Defense Labs
Attack and Defense Labs
人人都是产品经理
人人都是产品经理
The Cloudflare Blog
PCI Perspectives
PCI Perspectives
V2EX - 技术
V2EX - 技术
Google DeepMind News
Google DeepMind News
Last Week in AI
Last Week in AI
aimingoo的专栏
aimingoo的专栏
Cisco Talos Blog
Cisco Talos Blog
N
News and Events Feed by Topic
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
SegmentFault 最新的问题

博客园 - Easy Company

如何取得显示实现方法的MethodInfo SQL Server 2008中许多兼容性上的问题 Mock 对象何时使用? ThreadPool 在.Net 2.0 SP1中的部分变化可能会让你的程序停止工作 目前不能使用SQL Server 2008 CTP February 2008存储Team Foundation Server 2008的数据 Javascript操作在各浏览器下的性能比较 WCF Web 编程模型资源 代码行数引起的思考 ASP.NET 2.0中使用强类型访问PreviousPage属性页的控件 Silverlight 与 Microsoft ASP.NET Futures (July 2007) 更新 VS 2008 和.NET 3.5 Beta 2 安装注意事项 Partial Methods CIL(Common Intermediate Language)指令集 刚刚下载了 Visual Studio 2005 Service Pack 1 (SP1) 使用 Facade 设计模式管理 ASP.Net Session 变量 .Net 中的日志 使用 Membership 时获取用户的最后登录时间 How To 推荐用于 AJAX 页面的进度指示器图片
在按钮点击后禁用它直到操作完成 - Easy Company - 博客园
Easy Company · 2007-11-07 · via 博客园 - Easy Company

好久没有写东西了,今天将以前给同事写的一段代码改了一下共享出来。这段代码用于实现在点击按钮后禁用它直到操作完成。有更好的方法大家可以讨论!

<%@ 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)
    {
        LinkButtonClickCount
++;
        System.Threading.Thread.Sleep (
2000);
        Label1.Text 
= "link button:" + DateTime.Now.ToString ()
            
+ "<br/>count:" + LinkButtonClickCount.ToString ();
    }

    protected 

void ibtn_Click (object sender, ImageClickEventArgs e)
    {
        ImageButtonClickCount
++;
        System.Threading.Thread.Sleep (
2000);
        Label1.Text 
= "image button:" + DateTime.Now.ToString ()
            
+ "<br/>count:" + ImageButtonClickCount.ToString ();
    }
int LinkButtonClickCount
    {
        get
        {
            object tmp 
= ViewState["LinkButtonClickCount"];
            
return (tmp == null? 0 : (int)tmp;
        }
        set { ViewState[
"LinkButtonClickCount"= value; }
    }
    
int ImageButtonClickCount
    {
        get
        {
            object tmp 
= ViewState["ImageButtonClickCount"];
            
return (tmp == null? 0 : (int)tmp;
        }
        set { ViewState[
"ImageButtonClickCount"= value; }
    }
</script><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    
<title>无标题页</title>
</head>
<body>
    
<form id="form1" runat="server">
        
<div>
            
<asp:Button ID="btn" runat="server" Text="What time is it, please!" 
            OnClick
="btn_Click" />
            
<asp:LinkButton ID="lbtn" runat="server" OnClick="lbtn_Click">
        What time is it, please!
</asp:LinkButton>
            
<asp:ImageButton ID="ibtn" runat="server" 
              AlternateText
="What time is it, please!"
              Height
="30px" OnClick="ibtn_Click" 
              ImageUrl
="http://www.ikea.com/ms/img/menu/products/32x32/clocks_32x32.gif" 
            
/>
            
<br />
            
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
        
</div>
    
</form>
</body>
</html>