asp.net ajax 提交中,暂停提交


 from msdn
 protected void Button1_Click(object sender, EventArgs e)
        
{
            System.Threading.Thread.Sleep(
3000);
            Label1.Text 
= System.DateTime.Now.ToString();
        }


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!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 runat="server">
    
<title>Untitled Page</title>
</head>
<body>
    
<form id="form1" runat="server">
    
<div>
    
    
</div>
    
<asp:ScriptManager ID="ScriptManager1" runat="server">
    
    
</asp:ScriptManager>
    
    
<script type="text/javascript">
    
var prm = Sys.WebForms.PageRequestManager.getInstance();
   prm.add_initializeRequest(InitializeRequest);
   
function InitializeRequest(sender, args) {
    
if (prm.get_isInAsyncPostBack())
      
{
         args.set_cancel(
true);
      }

   }

    
function AbortPostBack() {
      
if (prm.get_isInAsyncPostBack()) {
           prm.abortPostBack();
      }
        
    }

    
</script>

    
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        
<ContentTemplate>
            
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
            
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        
</ContentTemplate>
    
</asp:UpdatePanel>
    
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
        
<ProgressTemplate>
            正在加载数据!
<br />
            
<input type="button" value="stop" onclick="AbortPostBack()" />

        
</ProgressTemplate>
    
</asp:UpdateProgress>
    
</form>
</body>
</html>

posted on   gwazy  阅读(817)  评论(1编辑  收藏  举报

编辑推荐:
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 用 C# 插值字符串处理器写一个 sscanf
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
· .NET Core内存结构体系(Windows环境)底层原理浅谈
阅读排行:
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 本地部署DeepSeek后,没有好看的交互界面怎么行!
· 趁着过年的时候手搓了一个低代码框架
· 推荐一个DeepSeek 大模型的免费 API 项目!兼容OpenAI接口!
· 用 C# 插值字符串处理器写一个 sscanf

导航

< 2007年12月 >
25 26 27 28 29 30 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示