asp.net ajax Sys.WebForms PageRequestManager class

Sys.WebForms.PageRequestManager 
        PageRequestManager 可以管理由 UpdatePanel 启动的异步回调。它还负责在异步回调完成后更新 UpdatePanel 内的内容。
        PageRequestManager 可以在更新前和更新后激发浏览器中的事件。您可以将 JavaScript 中的这些事件关联起来,并运行可以提醒用户注意更新内容的代码。它每次还会激发代表 UpdatePanel 控件完成而启动的异步回调,并且会更新这个 UpdatePanel 中的内容
You do not create an instance of the PageRequestManager directly. When partial-page rendering is enabled, an instance of the PageRequestManager class is automatically available. You can access it through the getInstance method


The PageRequestManager class defines events that you can use to customize your page's partial-page rendering
Event

initializeRequest

Raised before processing of the asynchronous request starts. You can use this event to cancel a postback.

beginRequest

Raised before processing of an asynchronous postback starts and the postback is sent to the server. You can use this event to set request headers or to begin an animation that indicates that the page is processing.

pageLoading               

Raised after the response from the server to an asynchronous postback is received but before any content on the page is updated. You can use this event to provide a custom transition effect for updated content.

pageLoaded

Raised after all content on the page is refreshed, as a result of either a synchronous or an asynchronous postback. You can use this event to provide a custom transition effect for updated content.

endRequest

Raised after an asynchronous postback is finished and control has been returned to the browser. You can use this event to provide a notification to users or to log errors.

方法
Sys.WebForms.PageRequestManager.abortPostBack()
Sys.WebForms.PageRequestManager.dispose()
Sys.WebForms.PageRequestManager.getInstance()

属性
Sys.WebForms.PageRequestManager.isInAsyncPostBack (Property)   确定在进程中是否有一个异步回送

--------------------------------事件传递参数----------------------------------
属于Sys.WebForms  Namespace
Sys.WebForms.InitializeRequestEventArgs Class
:Used by the initializeRequest event of the Sys.WebForms.PageRequestManager class to pass argument information to event handlers.
getPostElement (Property)
Request  (Property)
Cancel  (Property)

Sys.WebForms.BeginRequestEventArgs Class
Used by the beginRequest event of the Sys.WebForms.PageRequestManager class to pass argument information to event handlers. The beginRequest event is raised just before the postback request is made
getPostElement (Property)
Request (Property)

Sys.Web.PageLoadedEventArgs Class
Used by the pageLoaded event of the Sys.WebForms.PageRequestManager class to send event data that represents the UpdatePanel controls that were updated and created in the most recent postback.
dataItems        (Property)
PanelsCreated (Property) 得到Html <div>的数组元素 包含最后异步请求被创建的updatePanel
PanelsUpdated (Property)得到Html <div>的数组元素 包含最后异步请求被更新的updatePanel

Sys.Web.PageLoadingEventArgs Class
Used by the pageLoading event of the Sys.WebForms.PageRequestManager class to send event data that represents the UpdatePanel controls being updated and deleted as a result of the most recent postback.
dataItems        (Property)
PanelsDeleting(Property) 得到Html <div>的数组元素 当前异步请求将被删除的updatePanel
PanelsUpdating (Property)得到Html <div>的数组元素 当前异步请求将被更新的updatePanel

Sys.WebForms.EndRequestEventArgs Class
Used by the endRequest event of the Sys.WebForms.PageRequestManager class to pass argument information to event handlers. The endRequest event is raised just after the postback request has finished processing.
DataItems (Property)
error         (Property)
errorHandled (Property)
response (Property)

------------------------------------调用方式------------------------------------
 add_eventname 和 reomve_eventname 方法来添加或移除事件
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(*)
Sys.WebForms.PageRequestManager.getInstance().remove_initializeRequest(*)

------------------------------------不使用 UpdatePanel ---------------------------
        UpdatePanel 的异步 XML-HTTP 请求中所增长的数据几乎与在标准 ASP .NET 回发中增长的数据相同。在回发期间传送到服务器的视图状态数据(与其他数据)也会在 UpdatePanel 回调期间传送。UpdatePanel 虽易于使用,但是通信效率不高。
        UpdatePanel 控件的好处之一是服务器端的事件处理程序(如 GetCityState)在异步回调内执行的操作与在传统回发中所执行的操作一样。这意味着该页面上的控件必须被实例化,它们必须有权访问视图状态等。
        怎么不使用UpdatePanel,在客户端调用服务器方法: 通过特殊的 PageMethods 代理从 JavaScript 调用。
视图状态和其他输入未被传送到服务器。并且既然页面方法都是静态的,那么就可以在没有实例化页面对象的情况下调用它们。对页面方法的调用不会调用由常规 ASP.NET 请求触发的页面生命周期。

你可能感兴趣的:(asp.net)