zoukankan      html  css  js  c++  java
  • PRM–initializeRequest事件

    PRM–initializeRequest事件
    •参数类型:InitializeRequestEventArgs
    –request属性:用于获得WebRequest对象(用于请求的信息)
    –postBackElement:触发异步刷新的DOM元素
    •常用操作:
    –读取请求信息
    –取消此次异步更新

    优先级高的异步刷新
    aspx
    <%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="1_PrecedencePostBack.aspx.cs" Inherits="_1_PrecedencePostBack" Title="PrecedencePostBack" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="0" DynamicLayout="false">
        
    <ProgressTemplate>
            
    <span style="color:Red">Loading</span>
        
    </ProgressTemplate>
    </asp:UpdateProgress>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        
    <ContentTemplate>
            
    <%= DateTime.Now %><br />
            
    <asp:Label ID="Label1" runat="server" Text=""></asp:Label><br />
            
    <asp:Button ID="btnPrecedence" runat="server" Text="优先" OnClick="Button_OnClick" />
            
    <asp:Button ID="Button2" runat="server" Text="普通" OnClick="Button_OnClick" />
        
    </ContentTemplate>
    </asp:UpdatePanel>

    <script type="text/javascript" language="javascript">
        var lastPostBackButtonId 
    = null;
        var btnPrecedenceId 
    = "<%= this.btnPrecedence.ClientID %>";
        
        Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(
            function(sender, e)
            {
                var prm 
    = Sys.WebForms.PageRequestManager.getInstance();
                
    if (prm.get_isInAsyncPostBack())
                {
                    
    if (lastPostBackButtonId == btnPrecedenceId)
                    {
                        e.set_cancel(
    true);
                        
                        
    if (e.get_postBackElement().id == btnPrecedenceId)
                        {
                            showMessage(
    "不可重复发起优先的刷新。");
                        }
                        
    else
                        {
                            showMessage(
    "请等待优先的刷新结束。");
                        }
                        
                        
    return;
                    }
                    
    else if (e.get_postBackElement().id == btnPrecedenceId)
                    {
                        showMessage(
    "发起优先的刷新,普通的刷新将被取消。");
                    }
                    
    else
                    {
                        showMessage(
    "重新发起普通的刷新,前一次提交将被取消。");
                    }
                }
                
                lastPostBackButtonId 
    = e.get_postBackElement().id;
            });
    </script>

    </asp:Content>

    cs
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        
    protected void Button_OnClick(object sender, EventArgs e)
        {
            Thread.Sleep(
    3000);

            Button button 
    = sender as Button;
            
    this.Label1.Text = String.Format("您点击了“{0}”按钮", button.Text);
        }

    使用Thread.Sleep(3000);需要导入命名空间System.Threading;
  • 相关阅读:
    数据结构与算法分析(1)引论
    每天一个Linux命令(1)ls命令
    Oracle ->> 层级查询语句(hierarchical query)connect by
    SQL Server ->> GROUPING SETS, CUBE, ROLLUP, GROUPING, GROUPING_ID
    Oracle ->> 日期函数
    Oracle ->> 变量赋值 Demo
    SQL SERVER ->> BCP导出数据到平面文件
    SQL SERVER ->> CXPacket等待类型
    SQL SERVER ->> Wait Stats
    SQL SERVER ->> Columnstore Index
  • 原文地址:https://www.cnblogs.com/timy/p/1169826.html
Copyright © 2011-2022 走看看