Documentation for: ASP.NET Ajax Version 1.0

This documentation is for a previous version. For the current released version, see the ASP.NET Ajax documentation on MSDN.








Sys.WebForms.EndRequestEventArgs Sample


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

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

<script runat="server">

    protected void ErrorProcessClick_Handler(object sender, EventArgs e)
        // This handler demonstrates an error condition. In this example
        // the server error gets intercepted on the client and an alert is shown. 
        throw new ArgumentException();
    protected void SuccessProcessClick_Handler(object sender, EventArgs e)
        // This handler demonstrates no server side exception.
        UpdatePanelMessage.Text = "The asynchronous postback completed successfully.";


<html xmlns="">
<head runat="server">
    <title>PageRequestManager endRequestEventArgs Example</title>
    <style type="text/css">
    body {
        font-family: Tahoma;
    position: absolute; width: 90%; top: 0%;
    visibility: hidden; z-index: 99; background-color: #ffff99;
    font-size: larger;  font-family: Tahoma; 
    border-right: navy thin solid; border-top: navy thin solid; 
    border-left: navy thin solid; border-bottom: navy thin solid;    
    <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server"/>

            <script type="text/javascript" language="javascript">
                var divElem = 'AlertDiv';
                var messageElem = 'UpdatePanelMessage';
                function ToggleAlertDiv(visString)
                     var adiv = $get(divElem);
            = visString;
                function ClearErrorState() {
                     $get(messageElem).innerHTML = '';
                function EndRequestHandler(sender, args)
                   if (args.get_error() != null)
                       var errorName = args.get_error().name;
                       if (errorName.length > 0 )
                          $get(messageElem).innerHTML = 'The panel did not update successfully.';

            <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="Server">
                    <asp:Panel ID="Panel1" runat="server" GroupingText="Update Panel">
                        <asp:Label ID="UpdatePanelMessage" runat="server" />
                        <br />
                        Last update:
                        <%= DateTime.Now.ToString() %>
                        <br />
                        <asp:Button runat="server" ID="Button1" Text="Submit Successful Async Postback"
                            OnClick="SuccessProcessClick_Handler" OnClientClick="ClearErrorState()" />
                        <asp:Button runat="server" ID="Button2" Text="Submit Async Postback With Error"
                            OnClick="ErrorProcessClick_Handler" OnClientClick="ClearErrorState()" />
                        <br />
            <div id="AlertDiv" class="AlertStyle" style="">
                <div id="AlertMessage" style="float: left">
                    There was a problem processing the last request.
                <div id="AlertLinks" style="float: right">
                    <a title="Hide this alert." href="#" onclick="ClearErrorState()">
                        close</a> | <a title="Send an email notifying the Web site owner."
                            href="" onclick="ToggleAlertDiv('hidden', 'AlertDiv')">