Page::AddOnPreRenderCompleteAsync Method (BeginEventHandler, EndEventHandler, Object)
Registers beginning and ending event handler delegates for an asynchronous page.
Assembly: System.Web (in System.Web.dll)
public: void AddOnPreRenderCompleteAsync( BeginEventHandler^ beginHandler, EndEventHandler^ endHandler, Object^ state )
Parameters
- beginHandler
- Type: System.Web::BeginEventHandler
The delegate for the BeginEventHandler method.
- endHandler
- Type: System.Web::EndEventHandler
The delegate for the EndEventHandler method.
- state
- Type: System::Object
An object containing state information for the event handlers.
| Exception | Condition |
|---|---|
| InvalidOperationException | The <async> page directive is not set to true. - or - The AddOnPreRenderCompleteAsync method is called after the PreRender event. |
| ArgumentNullException | The BeginHandler or EndHandler is nullptr. |
Use the AddOnPreRenderCompleteAsync method to add handlers that require state information to an asynchronous Web page. The object passed in the state parameter can be any object that your application requires to transfer information between event handler delegates specified in the beginHandler and the endHandler parameters.
You can register multiple asynchronous handlers; however, only one handler runs at a time. If you want to process multiple asynchronous methods simultaneously, you should use a single BeginEventHandler method and launch multiple asynchronous operations from that handler.
The asynchronous handlers are called between the PreRender and PreRenderComplete events.
First, all Page events (through the PreRender event) are run, and then each registered BeginEventHandler method is called. When the handler completes, the corresponding EndEventHandler method is called. If there are multiple asynchronous handlers, the next handler is called.
After the registered asynchronous event handlers have been called, the rest of the page events are called, beginning with the PreRenderComplete event.
The following code example uses an asynchronous request to display the HTML source code of the local Web server's default page in a TextBox control.
Security Note: |
|---|
This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see Script Exploits Overview. |
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Security Note: