|
Este artículo proviene de un motor de traducción automática. Mueva el puntero sobre las frases del artículo para ver el texto original. Más información.
|
Traducción
Original
|
UpdatePanel (Clase)
Espacio de nombres: System.Web.UI
Ensamblado: System.Web.Extensions (en System.Web.Extensions.dll)
El tipo UpdatePanel expone los siguientes miembros.
| Nombre | Descripción | |
|---|---|---|
![]() | Adapter | |
![]() | AppRelativeTemplateSourceDirectory | |
![]() | Attributes | |
![]() | BindingContainer | Infraestructura. |
![]() | ChildControlsCreated | |
![]() | ChildrenAsTriggers | |
![]() | ClientID | |
![]() | ClientIDMode | |
![]() | ClientIDSeparator | |
![]() | ContentTemplate | |
![]() | ContentTemplateContainer | |
![]() | Context | |
![]() | Controls | |
![]() | DataItemContainer | |
![]() | DataKeysContainer | |
![]() | DesignMode | |
![]() | EnableTheming | |
![]() | EnableViewState | |
![]() | Events | |
![]() | HasChildViewState | |
![]() | ID | |
![]() | IdSeparator | Infraestructura. |
![]() | IsChildControlStateCleared | |
![]() | IsInPartialRendering | |
![]() | IsTrackingViewState | |
![]() | IsViewStateEnabled | |
![]() | LoadViewStateByID | |
![]() | NamingContainer | |
![]() | Page | |
![]() | Parent | |
![]() | RenderingCompatibility | |
![]() | RenderMode | |
![]() | RequiresUpdate | |
![]() | Site | |
![]() | SkinID | |
![]() | TemplateControl | |
![]() | TemplateSourceDirectory | |
![]() | Triggers | |
![]() | UniqueID | |
![]() | UpdateMode | |
![]() | ValidateRequestMode | |
![]() | ViewState | |
![]() | ViewStateIgnoresCase | |
![]() | ViewStateMode | |
![]() | Visible |
| Nombre | Descripción | |
|---|---|---|
![]() | AddedControl | |
![]() | AddParsedSubObject | |
![]() | ApplyStyleSheetSkin | |
![]() | BeginRenderTracing | |
![]() | BuildProfileTree | Infraestructura. |
![]() | ClearCachedClientID | Infraestructura. |
![]() | ClearChildControlState | |
![]() | ClearChildState | |
![]() | ClearChildViewState | |
![]() | ClearEffectiveClientIDMode | Infraestructura. |
![]() | CreateChildControls | |
![]() | CreateContentTemplateContainer | |
![]() | CreateControlCollection | |
![]() | DataBind() | |
![]() | DataBind(Boolean) | |
![]() | DataBindChildren | |
![]() | Dispose | |
![]() | EndRenderTracing | |
![]() | EnsureChildControls | |
![]() | EnsureID | |
![]() | Equals(Object) | |
![]() | Finalize | |
![]() | FindControl(String) | |
![]() | FindControl(String, Int32) | Infraestructura. |
![]() | Focus | |
![]() | GetDesignModeState | Infraestructura. |
![]() | GetHashCode | |
![]() | GetRouteUrl(Object) | |
![]() | GetRouteUrl(RouteValueDictionary) | |
![]() | GetRouteUrl(String, Object) | |
![]() | GetRouteUrl(String, RouteValueDictionary) | |
![]() | GetType | |
![]() | GetUniqueIDRelativeTo | |
![]() | HasControls | |
![]() | HasEvents | |
![]() | Initialize | |
![]() | IsLiteralContent | Infraestructura. |
![]() | LoadControlState | |
![]() | LoadViewState | |
![]() | MapPathSecure | |
![]() | MemberwiseClone | |
![]() | OnBubbleEvent | |
![]() | OnDataBinding | |
![]() | OnInit | |
![]() | OnLoad | |
![]() | OnPreRender | |
![]() | OnUnload | |
![]() | OpenFile | |
![]() | RaiseBubbleEvent | |
![]() | RemovedControl | |
![]() | Render | |
![]() | RenderChildren | |
![]() | RenderControl(HtmlTextWriter) | |
![]() | RenderControl(HtmlTextWriter, ControlAdapter) | |
![]() | ResolveAdapter | |
![]() | ResolveClientUrl | |
![]() | ResolveUrl | |
![]() | SaveControlState | |
![]() | SaveViewState | |
![]() | SetDesignModeState | |
![]() | SetRenderMethodDelegate | Infraestructura. |
![]() | SetTraceData(Object, Object) | |
![]() | SetTraceData(Object, Object, Object) | |
![]() | ToString | |
![]() | TrackViewState | |
![]() | Update |
| Nombre | Descripción | |
|---|---|---|
![]() | DataBinding | |
![]() | Disposed | |
![]() | Init | |
![]() | Load | |
![]() | PreRender | |
![]() | Unload |
| Nombre | Descripción | |
|---|---|---|
![]() | FindDataSourceControl | |
![]() | FindFieldTemplate | |
![]() | FindMetaTable |
Introduction
Actualizar el contenido de UpdatePanel
Si la propiedad UpdateMode del control UpdatePanel se establece en Always, el contenido del control UpdatePanel se actualiza en cada postback que se origine en la página. Se incluyen los postback asincrónicos de controles que están dentro de otros controles UpdatePanel y postbacks de controles que no están dentro de los controles UpdatePanel. Si la propiedad UpdateMode se establece en Conditional, el contenido del control UpdatePanel se actualiza en los siguientes casos: Al llamar explícitamente al método Update del control UpdatePanel. Cuando se anida el control UpdatePanel dentro de otro control UpdatePanel y se actualiza el panel primario. Cuando un control que se define como desencadenador mediante la propiedad Triggers del control UpdatePanel genera un postback. En este escenario, el control activa explícitamente una actualización del contenido del panel. El control puede ser interior o exterior respecto al control UpdatePanel al que se asocia el desencadenador. Cuando la propiedad ChildrenAsTriggers se establece en true y un control secundario del control UpdatePanel provoca un postback. Los controles secundarios de los controles UpdatePanel anidados no provocan actualizaciones del control UpdatePanel externo a menos que se definan explícitamente como desencadenadores.
Uso de UpdatePanel
En controles de usuario. En las páginas maestras y de contenido. Anidados en otros controles UpdatePanel. Dentro de controles con plantilla como los controles GridView o Repeater.
Aplicar estilos
<asp:UpdatePanel runat="server" class="myStyle"> </asp:UpdatePanel>
<div id="ctl00_MainContent_UpdatePanel1" class="MyStyle"> </div>
Sintaxis de la declaración
<asp:UpdatePanel ChildrenAsTriggers="True|False" EnableTheming="True|False" EnableViewState="True|False" ID="string" OnDataBinding="DataBinding event handler" OnDisposed="Disposed event handler" OnInit="Init event handler" OnLoad="Load event handler" OnPreRender="PreRender event handler" OnUnload="Unload event handler" RenderMode="Block|Inline" runat="server" SkinID="string" UpdateMode="Always|Conditional" Visible="True|False" > <ContentTemplate> <!-- child controls --> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="string" EventName="string" /> <asp:PostBackTrigger ControlID="string" /> </Triggers> </asp:UpdatePanel>
Controles dentro de un control UpdatePanel
<%@ 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"> void DropDownSelection_Change(Object sender, EventArgs e) { Calendar1.DayStyle.BackColor = System.Drawing.Color.FromName(ColorList.SelectedItem.Value); } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { SelectedDate.Text = Calendar1.SelectedDate.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>UpdatePanel Example</title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Calendar ID="Calendar1" ShowTitle="True" OnSelectionChanged="Calendar1_SelectionChanged" runat="server" /> <div> Background: <br /> <asp:DropDownList ID="ColorList" AutoPostBack="True" OnSelectedIndexChanged="DropDownSelection_Change" runat="server"> <asp:ListItem Selected="True" Value="White"> White </asp:ListItem> <asp:ListItem Value="Silver"> Silver </asp:ListItem> <asp:ListItem Value="DarkGray"> Dark Gray </asp:ListItem> <asp:ListItem Value="Khaki"> Khaki </asp:ListItem> <asp:ListItem Value="DarkKhaki"> D ark Khaki </asp:ListItem> </asp:DropDownList> </div> <br /> Selected date: <asp:Label ID="SelectedDate" runat="server">None.</asp:Label> </ContentTemplate> </asp:UpdatePanel> <br /> </div> </form> </body> </html>
Escenario de maestro/detalle con controles UpdatePanel
<%@ 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 GridView1_SelectedIndexChanged(object sender, EventArgs e) { SqlDataSource2.SelectParameters["OrderID"].DefaultValue = GridView1.SelectedDataKey.Value.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>UpdatePanel Example</title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="OrdersPanel" UpdateMode="Conditional" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" AllowPaging="True" AllowSorting="True" Caption="Orders" DataKeyNames="OrderID" DataSourceID="SqlDataSource1" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" runat="server" > <Columns> <asp:CommandField ShowSelectButton="True"></asp:CommandField> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [OrderID], [CustomerID], [EmployeeID], [OrderDate] FROM [Orders]"> </asp:SqlDataSource> </ContentTemplate> </asp:UpdatePanel> <asp:UpdatePanel ID="OrderDetailsPanel" UpdateMode="Always" runat="server"> <ContentTemplate> <asp:DetailsView ID="DetailsView1" Caption="Order Details" DataKeyNames="OrderID,ProductID" DataSourceID="SqlDataSource2" runat="server"> <EmptyDataTemplate> <i>Select a row from the Orders table.</i> </EmptyDataTemplate> </asp:DetailsView> <asp:SqlDataSource ID="SqlDataSource2" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [OrderID], [ProductID], [UnitPrice], [Quantity], [Discount] FROM [Order Details] WHERE ([OrderID] = @OrderID)" runat="server"> <SelectParameters> <asp:Parameter Name="OrderID" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html>
Usar un control UpdatePanel en una plantilla
<%@ 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"> private void ChangeQuantity(object sender, int delta) { Label quantityLabel = (Label)((Button)sender).FindControl("QuantityLabel"); int currentQuantity = Int32.Parse(quantityLabel.Text); currentQuantity = Math.Max(0, currentQuantity + delta); quantityLabel.Text = currentQuantity.ToString(System.Globalization.CultureInfo.InvariantCulture); } private void OnDecreaseQuantity(object sender, EventArgs e) { ChangeQuantity(sender, -1); } private void OnIncreaseQuantity(object sender, EventArgs e) { ChangeQuantity(sender, 1); } protected void Button1_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); sb.Append("Beverage order:<br/>"); foreach (GridViewRow row in GridView1.Rows) { if (row.RowType == DataControlRowType.DataRow) { Label quantityLabel = (Label)row.FindControl("QuantityLabel"); int currentQuantity = Int32.Parse(quantityLabel.Text); sb.Append(row.Cells[0].Text + " : " + currentQuantity + "<br/>"); } } SummaryLabel.Text = sb.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>UpdatePanel Inside GridView Template Example </title> </head> <body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:GridView ID="GridView1" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" runat="server"> <Columns> <asp:BoundField DataField="ProductName" HeaderText="ProductName" /> <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" /> <asp:TemplateField HeaderText="Quantity"> <ItemTemplate> <asp:UpdatePanel ID="QuantityUpdatePanel" UpdateMode="Conditional" runat="server" > <ContentTemplate> <asp:Label ID="QuantityLabel" Text="0" runat="server" /> <asp:Button ID="DecreaseQuantity" Text="-" OnClick="OnDecreaseQuantity" runat="server" /> <asp:Button ID="IncreaseQuantity" Text="+" OnClick="OnIncreaseQuantity" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:UpdatePanel ID="SummaryUpdatePanel" UpdateMode="Conditional" runat="server"> <ContentTemplate> <asp:Button ID="Button1" OnClick="Button1_Click" Text="Get Summary" runat="server" /> <br /> <asp:Label ID="SummaryLabel" runat="server"> </asp:Label> </ContentTemplate> </asp:UpdatePanel> <asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT [ProductName], [UnitPrice] FROM [Alphabetical list of products] WHERE ([CategoryName] LIKE '%' + @CategoryName + '%')" runat="server"> <SelectParameters> <asp:Parameter DefaultValue="Beverages" Name="CategoryName" Type="String" /> </SelectParameters> </asp:SqlDataSource> </div> </form> </body> </html>
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (no se admite el rol Server Core), Windows Server 2008 R2 (se admite el rol Server Core con SP1 o versiones posteriores; no se admite Itanium)
.NET Framework no admite todas las versiones de todas las plataformas. Para obtener una lista de las versiones compatibles, vea Requisitos de sistema de .NET Framework.

