Compartir a través de


Sys.WebForms.PageLoadedEventArgs (Clase)

Actualización: noviembre 2007

Utilizada por el evento pageLoaded de la clase Sys.WebForms.PageRequestManager para enviar datos de eventos que representan los controles de UpdatePanel que se actualizaron y crearon en la última devolución de datos.

Espacio de nombres:Sys.WebForms

Hereda:Sys.EventArgs

var args = new Sys.WebForms.PageLoadedEventArgs();

Constructores

Name

Description

Sys.WebForms.PageLoadedEventArgs (Constructor)

Inicializa una nueva instancia de la clase PageLoadedEventArgs.

Members

Name

Description

Sys.WebForms.PageLoadedEventArgs dataItems (Propiedad)

Obtiene una estructura de datos JSON que contiene los elementos de datos registrados mediante el método RegisterDataItem de la clase ScriptManager.

Sys.WebForms.PageLoadedEventArgs panelsCreated (Propiedad)

Obtiene una matriz de elementos HTML <div> que representan los controles UpdatePanel creados cuando DOM se actualizó durante la última devolución asincrónica.

Sys.WebForms.PageLoadedEventArgs panelsUpdated (Propiedad)

Obtiene una matriz de elementos HTML <div> que representan los controles UpdatePanel actualizados cuando DOM se actualizó durante la última devolución.

Nota

Esta clase contiene miembros privados que admiten la infraestructura de script de cliente y no está prevista su utilización directa desde el código. Los nombres de los miembros privados comienzan con un guión bajo (_).

Comentarios

El control UpdatePanel representa elementos <div> HTML. El evento pageLoaded contiene información sobre los elementos <div> de la página que se actualizaron y crearon. La propiedad panelsCreated es una matriz de elementos de panel que se crearon como resultado de la devolución de datos asincrónica actual. La propiedad panelsUpdated es una matriz de paneles que se actualizaron como resultado de la devolución de datos asincrónica actual.

Ejemplo

En el ejemplo siguiente se muestra cómo utilizar el evento pageLoaded para proporcionar un script que anima una región de la página durante una actualización parcial de página. Los datos de eventos (args) son un objeto PageLoadedEventArgs.

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    Protected Sub LinkButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        TextBox1.Text = DateTime.Now.ToString()
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>PageRequestManager pageLoaded Event Example</title>
    <style type="text/css">
        body {
            font-family: Tahoma;
        }
        .FieldSetStyle
        {
            width: 300px;
            height: 100px;
        }
        .UpdatePanelContainer
        {
            width: 330px;
            height:110px;
        }

    </style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />

        <script type="text/javascript">
        Type.registerNamespace("ScriptLibrary");
        ScriptLibrary.BorderAnimation = function(color, duration) {
            this._color = color;
            this._duration = duration;
        }
        ScriptLibrary.BorderAnimation.prototype = {
            animatePanel: function(panelElement) {
                var s = panelElement.style;
                s.borderWidth = '1px';
                s.borderColor = this._color;
                s.borderStyle = 'solid';
                window.setTimeout(
                    function() {{ s.borderWidth = 0; }},
                    this._duration
                );
            }
        }
        ScriptLibrary.BorderAnimation.registerClass('ScriptLibrary.BorderAnimation', null);

        var panelUpdatedAnimation = new ScriptLibrary.BorderAnimation('blue', 1000);
        var postbackElement;
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);

        function beginRequest(sender, args) {
            postbackElement = args.get_postBackElement();
        }
        function pageLoaded(sender, args) {
            var updatedPanels = args.get_panelsUpdated();
            if (typeof(postbackElement) === "undefined") {
                return;
            } 
            else if (postbackElement.id.toLowerCase().indexOf('external') > -1) {
                for (i=0; i < updatedPanels.length; i++) {            
                    panelUpdatedAnimation.animatePanel(updatedPanels[i]);
                }
            }

        }
        </script>

        <p>
            <asp:LinkButton ID="ExternalButton" runat="server" OnClick="LinkButton_Click">
            Update the panel with animation.
            </asp:LinkButton>
        </p>
        <hr />
        <div class="UpdatePanelContainer">
            <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="ExternalButton" />
                </Triggers>
                <ContentTemplate>
                    <fieldset id="FieldSet1" class="FieldSetStyle" runat="server">
                        <legend>UpdatePanel</legend>
                        <asp:TextBox runat="server" ID="TextBox1" />
                        <br />
                        <asp:LinkButton ID="InternalButton" runat="server" OnClick="LinkButton_Click">
                        Update the panel with no animation.
                        </asp:LinkButton>
                    </fieldset>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
    protected void LinkButton_Click(object sender, EventArgs e)
    {
        TextBox1.Text = DateTime.Now.ToString();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>PageRequestManager pageLoaded Event Example</title>
    <style type="text/css">
        body {
            font-family: Tahoma;
        }
        .FieldSetStyle
        {
            width: 300px;
            height: 100px;
        }
        .UpdatePanelContainer
        {
            width: 330px;
            height:110px;
        }

    </style>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server" />

        <script type="text/javascript">
        Type.registerNamespace("ScriptLibrary");
        ScriptLibrary.BorderAnimation = function(color, duration) {
            this._color = color;
            this._duration = duration;
        }
        ScriptLibrary.BorderAnimation.prototype = {
            animatePanel: function(panelElement) {
                var s = panelElement.style;
                s.borderWidth = '1px';
                s.borderColor = this._color;
                s.borderStyle = 'solid';
                window.setTimeout(
                    function() {{ s.borderWidth = 0; }},
                    this._duration
                );
            }
        }
        ScriptLibrary.BorderAnimation.registerClass('ScriptLibrary.BorderAnimation', null);

        var panelUpdatedAnimation = new ScriptLibrary.BorderAnimation('blue', 1000);
        var postbackElement;
        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(beginRequest);
        Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pageLoaded);

        function beginRequest(sender, args) {
            postbackElement = args.get_postBackElement();
        }
        function pageLoaded(sender, args) {
            var updatedPanels = args.get_panelsUpdated();
            if (typeof(postbackElement) === "undefined") {
                return;
            } 
            else if (postbackElement.id.toLowerCase().indexOf('external') > -1) {
                for (i=0; i < updatedPanels.length; i++) {            
                    panelUpdatedAnimation.animatePanel(updatedPanels[i]);
                }
            }

        }
        </script>

        <p>
            <asp:LinkButton ID="ExternalButton" runat="server" OnClick="LinkButton_Click">
            Update the panel with animation.
            </asp:LinkButton>
        </p>
        <hr />
        <div class="UpdatePanelContainer">
            <asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="ExternalButton" />
                </Triggers>
                <ContentTemplate>
                    <fieldset id="FieldSet1" class="FieldSetStyle" runat="server">
                        <legend>UpdatePanel</legend>
                        <asp:TextBox runat="server" ID="TextBox1" />
                        <br />
                        <asp:LinkButton ID="InternalButton" runat="server" OnClick="LinkButton_Click">
                        Update the panel with no animation.
                        </asp:LinkButton>
                    </fieldset>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
    </form>
</body>
</html>

Vea también

Referencia

UpdatePanel

ScriptManager

Sys.WebForms.PageRequestManager (Clase)