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

    PRM–endRequest事件
    •参数类型:EndRequestEventArgs
    –dataItems属性:获得服务器端注册的数据项
    –error属性:获得异步刷新时获得的错误
    –errorHandled属性:表明错误是否已被处理了
    –response属性:获得这次请求获得的结果对象
    •常用操作:
    –处理异步刷新结果(异常、超时、取消, etc.)
    –获得请求结果中额外的信息
    –(能够)获得服务器端注册的数据项

    处理异步刷新结果
    aspx
    <%@ Page Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="5_HandleResponse.aspx.cs" Inherits="_5_HandleResponse" Title="HandleResponse" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

        
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            
    <ContentTemplate>
                
    <%= DateTime.Now %><br />
                
    <asp:Button ID="btnError" runat="server" Text="Error" OnClick="btnError_Click" />
                
    <asp:Button ID="btnTimeout" runat="server" Text="Timeout" OnClick="btnTimeout_Click" />
                
    <input type="button" value="Abort" onclick="Sys.WebForms.PageRequestManager.getInstance().abortPostBack();" />
                
    <asp:Button ID="btnDataItem" runat="server" Text="Register DataItem" OnClick="btnDataItem_Click" />
            
    </ContentTemplate>
        
    </asp:UpdatePanel>
        
        
    <script language="javascript" type="text/javascript">
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(
                function(sender, e)
                {
                    
    if (e.get_error())
                    {
                        e.set_errorHandled(
    true);
                        
                        
    if (e.get_response().get_timedOut())
                        {
                            showMessage(
    "您的请求已超时。");
                        }
                        
    else if (e.get_response().get_statusCode() != 200)
                        {
                            showMessage(
    "遇到未知错误。");
                        }
                        
    else
                        {
                            showMessage(e.get_error().message);
                        }
                    }
                    
    else if (e.get_response().get_aborted())
                    {
                        showMessage(
    "您的请求已被取消。");
                    }
                    
    else
                    {
                        var upId 
    = "<%= this.UpdatePanel1.ClientID %>";
                        var item 
    = e.get_dataItems()[upId];
                        showMessage(
    "您注册了:" + item);
                    }
                });
        
    </script>

    </asp:Content>

    cs
        protected void Page_Load(object sender, EventArgs e)
        {
            ScriptManager.GetCurrent(
    this).AsyncPostBackTimeout = 3;
        }

        
    protected void btnError_Click(object sender, EventArgs e)
        {
            
    int two = 2;
            
    int i = 3 / (two - 2);
        }

        
    protected void btnTimeout_Click(object sender, EventArgs e)
        {
            Thread.Sleep(
    5000);
        }

        
    protected void btnDataItem_Click(object sender, EventArgs e)
        {
            ScriptManager.GetCurrent(
    this).RegisterDataItem(this.UpdatePanel1, DateTime.Now.ToString());
        }
  • 相关阅读:
    关于串口
    assigning to uiimagepickercontrollerdelegate from incompatible type
    CodeSign error: code signing is required for product type 'Application' in SDK 'iOS 7.0'
    使用和不使用navigationbar分别处理显示和返回页面
    iphone坐标系统
    A valid provisioning profile for this executable was not found.
    Could not change executable permissions on the application
    Code Sign error: a valid provisioning profile matching the application's Identifier 'com. sensoSource.VoiceRecorder' could not be found
    从零开始开发iPhone,教你如何在真机调试iPhone应用程序
    iPhone 证书导出分享给多个开发人员操作
  • 原文地址:https://www.cnblogs.com/timy/p/1169869.html
Copyright © 2011-2022 走看看