Sys.WebForms.PageRequestManager beginRequest Event

Raised before the processing of an asynchronous postback starts and the postback request is sent to the server.





The name of the handler method that will be called.

The beginRequest event is raised before the processing of an asynchronous postback starts and the postback is sent to the server. You can use this event to call custom script to set a request header or to start an animation that notifies the user that the postback is being processed.

For more information about the PageRequestManager event model, see Working with Partial-Page Rendering Events.

The following example shows how to use the beginRequest function to display a simple progress notification during asynchronous postbacks. The Button1 control invokes the Thread.Sleep method to simulate a long-running process on the server. The Button2 control invokes a server handler that is faster. If you click Button2 while the asynchronous postback from Button1 is still processing, the Button1 postback is canceled.

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

<script runat="server">

    protected void ProcessClick_Handler(object sender, EventArgs e)


<html xmlns="">
<head id="Head1" runat="server">
    <title>PageRequestManager beginRequest Example</title>
    <style type="text/css">
    body {
        font-family: Tahoma;
      background-color: #FFC080;
      top: 95%;
      left: 1%;
      height: 20px;
      width: 270px;
      position: absolute;
      visibility: hidden;
    <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />

            <script type="text/javascript" language="javascript">
                function BeginRequestHandler(sender, args)
                     var elem = args.get_postBackElement();
                     ActivateAlertDiv('visible', 'AlertDiv', elem.value + ' processing...');
                function EndRequestHandler(sender, args)
                     ActivateAlertDiv('hidden', 'AlertDiv', '');
                function ActivateAlertDiv(visstring, elem, msg)
                     var adiv = $get(elem);
            = visstring;
                     adiv.innerHTML = msg;                     

            <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="Server">
                    <asp:Panel ID="Panel1" runat="server" GroupingText="Update Panel">
                        Last update:
                        <%= DateTime.Now.ToString()%>.
                        <br />
                        <asp:Button runat="server" ID="Button1" Text="Process 1" OnClick="ProcessClick_Handler" />
                        <asp:Button runat="server" ID="Button2" Text="Process 2" OnClick="ProcessClick_Handler" />
            <div id="AlertDiv" class="AlertStyle">