UpdatePanel 類別

定義

在不使用回傳的情況下,啟用網頁區段的部分呈現。Enables sections of a page to be partially rendered without a postback.

public ref class UpdatePanel : System::Web::UI::Control, System::Web::UI::IAttributeAccessor
[System.Drawing.ToolboxBitmap(typeof(EmbeddedResourceFinder), "System.Web.Resources.UpdatePanel.bmp")]
public class UpdatePanel : System.Web.UI.Control, System.Web.UI.IAttributeAccessor
type UpdatePanel = class
    inherit Control
    interface IAttributeAccessor
Public Class UpdatePanel
Inherits Control
Implements IAttributeAccessor
繼承
UpdatePanel
屬性
實作

範例

下列範例示範UpdatePanel控制項的各種用途。The following examples show various uses of the UpdatePanel control.

UpdatePanel 控制項內的控制項Controls Inside an UpdatePanel Control

下列範例顯示如何將控制項放在UpdatePanel控制項內, 以在張貼到伺服器時減少螢幕閃爍。The following example shows how to put controls inside an UpdatePanel control to reduce screen flicker when you post to the server. 在此範例中, Calendar DropDownList和控制項是在UpdatePanel控制項內。In this example, a Calendar and a DropDownList control are inside an UpdatePanel control. 根據預設, UpdateMode屬性為Always , 而ChildrenAsTriggers屬性為trueBy default, the UpdateMode property is Always and the ChildrenAsTriggers property is true. 因此, 面板的子控制項會造成非同步回傳。Therefore, child controls of the panel cause an asynchronous postback.


<%@ 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>

<%@ 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">
    Sub DropDownSelection_Change(ByVal Sender As Object, ByVal E As EventArgs)
        Calendar1.DayStyle.BackColor = _
        System.Drawing.Color.FromName(ColorList.SelectedItem.Value)
    End Sub

    Protected Sub Calendar1_SelectionChanged(ByVal Sender As Object, ByVal E As EventArgs)
        SelectedDate.Text = Calendar1.SelectedDate.ToString()
    End Sub

</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>

使用 UpdatePanel 控制項的主要/詳細案例Master/Detail Scenario with UpdatePanel Controls

在下列範例中, UpdatePanel會在主要/詳細資料案例中使用控制項, 以顯示 Northwind 資料庫中的訂單和訂單詳細資料。In the following example, an UpdatePanel control is used in a master/detail scenario that shows orders and order details from the Northwind database. 一個UpdatePanel 控制項GridView包含顯示訂單清單的控制項。One UpdatePanel control contains the GridView control that displays a list of orders. 第二UpdatePanel個控制項包含DetailsView一個控制項, 可顯示一個訂單的詳細資料。A second UpdatePanel control contains a DetailsView control that displays the details of one order. 當您從第一個資料表中選取訂單時, 該訂單的詳細資料會顯示在第二個數據表中。When you select an order from the first table, details for that order are displayed in the second table. 第二個數據表會根據第一個資料表中的選取專案以非同步方式更新。The second table is updated asynchronously based on the selection in the first table. [訂單摘要] 資料表中的排序和分頁作業也會造成部分更新。The sorting and paging operations in the orders summary table also cause partial updates.

<%@ 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>
<%@ 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 GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
        SqlDataSource2.SelectParameters("OrderID").DefaultValue = _
        GridView1.SelectedDataKey.Value.ToString()
    End Sub

</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>

如果您GridView將控制項放GridView UpdatePanel在控制項內, 則不支援將EnableSortingAndPagingCallbacks控制項的true屬性設定為。If you put a GridView control inside an UpdatePanel control, setting the GridView control's EnableSortingAndPagingCallbacks property to true is not supported. 不過, 由於UpdatePanel控制項支援非同步回傳, 因此在UpdatePanel控制項內GridView變更控制項的任何回傳都會造成與排序和分頁回呼相同的行為。However, because the UpdatePanel control supports asynchronous postbacks, any postbacks that change the GridView control inside an UpdatePanel control cause the same behavior as sorting and paging callbacks.

在範本中使用 UpdatePanel 控制項Using an UpdatePanel Control in a Template

在下列範例中, UpdatePanel控制項會在GridView控制項的專案範本中使用。In the following example, an UpdatePanel control is used in the item template of a GridView control. UpdatePanel每個資料列中的控制項都會自動產生。UpdatePanel controls in each data row are generated automatically. 每個資料UpdatePanel列的控制項Label都包含一個控制項, 可顯示該資料列Button中的專案數量, 以及減少並增加數量的控制項。Each row's UpdatePanel control contains a Label control to display the quantity of the item in that row and a Button control to decrease and increase the quantity.


<%@ 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>

<%@ 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">

    Private Sub ChangeQuantity(ByVal Sender As Button, ByVal delta As Integer)
        Dim quantityLabel As Label = CType(Sender.FindControl("QuantityLabel"), Label)
        Dim currentQuantity As Integer = Int32.Parse(quantityLabel.Text)
        currentQuantity = Math.Max(0, currentQuantity + delta)
        quantityLabel.Text = currentQuantity.ToString(System.Globalization.CultureInfo.InvariantCulture)
    End Sub

    Private Sub OnDecreaseQuantity(ByVal Sender As Object, ByVal E As EventArgs)
        ChangeQuantity(Sender, -1)
    End Sub

    Private Sub OnIncreaseQuantity(ByVal Sender As Object, ByVal E As EventArgs)
        ChangeQuantity(Sender, 1)
    End Sub

    Protected Sub Button1_Click(ByVal Sender As Object, ByVal E As EventArgs)
    
        Dim sb As New StringBuilder()
        sb.Append("Beverage order:<br/>")
        For Each row As GridViewRow In GridView1.Rows
        
            If row.RowType = DataControlRowType.DataRow Then
                Dim quantityLabel As Label = CType(row.FindControl("QuantityLabel"), Label)
                Dim currentQuantity As Int32 = Int32.Parse(quantityLabel.Text)
                sb.Append(row.Cells(0).Text + " : " & currentQuantity & "<br/>")
            End If
        Next
        SummaryLabel.Text = sb.ToString()

    End Sub
</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"
                                             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" 
                             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>

備註

本主題內容:In this topic:

簡介Introduction

UpdatePanel控制項是 ASP.NET 中 AJAX 功能的核心部分。UpdatePanel controls are a central part of AJAX functionality in ASP.NET. 它們會與ScriptManager控制項搭配使用, 以啟用部分頁面呈現。They are used with the ScriptManager control to enable partial-page rendering. 當只有部分頁面必須更新時, 部分頁面轉譯可減少同步回傳和完成頁面更新的需求。Partial-page rendering reduces the need for synchronous postbacks and complete page updates when only part of the page has to be updated. 部分頁面呈現可改善使用者體驗, 因為它可減少在整頁回傳期間發生的螢幕閃爍, 並改善網頁互動性。Partial-page rendering improves the user experience because it reduces the screen flicker that occurs during a full-page postback and improves Web page interactivity.

重新整理 UpdatePanel 內容Refreshing UpdatePanel Content

啟用部分頁面轉譯時, 控制項可以執行回傳來更新整個頁面, 或使用非同步回傳來更新一或多個UpdatePanel控制項的內容。When partial-page rendering is enabled, a control can perform a postback that updates the whole page or an asynchronous postback that updates the content of one or more UpdatePanel controls. 控制項是否會造成非同步回傳並更新UpdatePanel控制項, 取決於下列各項:Whether a control causes an asynchronous postback and updates an UpdatePanel control depends on the following:

  • 如果UpdatePanel控制項UpdateMode的屬性設定為Always, UpdatePanel則每次源自該頁面的回傳都會更新控制項的內容。If the UpdateMode property of the UpdatePanel control is set to Always, the UpdatePanel control's content is updated on every postback that originates from the page. 這包括來自其他UpdatePanel控制項內控制項的非同步回傳, 以及來自不在控制項內UpdatePanel之控制項的回傳。This includes asynchronous postbacks from controls that are inside other UpdatePanel controls and postbacks from controls that are not inside UpdatePanel controls.

  • 如果屬性設定為Conditional, UpdatePanel則在下列情況下會更新控制項的內容: UpdateModeIf the UpdateMode property is set to Conditional, the UpdatePanel control's content is updated in the following circumstances:

    • 當您明確地Update呼叫UpdatePanel控制項的方法時。When you call the Update method of the UpdatePanel control explicitly.

    • 當控制項嵌套在另一個UpdatePanel控制項內, 而且父面板已更新時。 UpdatePanelWhen the UpdatePanel control is nested inside another UpdatePanel control, and the parent panel is updated.

    • 當回傳是由使用Triggers UpdatePanel控制項的屬性定義為觸發程式的控制項所造成。When a postback is caused by a control that is defined as a trigger by using the Triggers property of the UpdatePanel control. 在此案例中, 控制項會明確觸發面板內容的更新。In this scenario, the control explicitly triggers an update of the panel content. 控制項可以是與觸發程式相關聯之UpdatePanel控制項的內部或外部。The control can be either inside or outside the UpdatePanel control that the trigger is associated with.

    • 當屬性設定為true , 且UpdatePanel控制項的子控制項導致回傳時。 ChildrenAsTriggersWhen the ChildrenAsTriggers property is set to true and a child control of the UpdatePanel control causes a postback. 除非已明確定義UpdatePanel為觸發程式, 否則嵌套控制項的子UpdatePanel控制項不會造成外部控制項的更新。Child controls of nested UpdatePanel controls do not cause an update to the outer UpdatePanel control unless they are explicitly defined as triggers.

ChildrenAsTriggers屬性設定為false , 並UpdateMode將屬性Always設為的組合不允許, 而且將會擲回例外狀況。The combination of setting the ChildrenAsTriggers property to false and the UpdateMode property to Always is not allowed and will throw an exception.

UpdatePanel當控制項執行非同步 post 時, 它會新增自訂 HTTP 標頭。When the UpdatePanel control performs an asynchronous post, it adds a custom HTTP header. 某些 proxy 會移除此自訂 HTTP 標頭。Some proxies remove this custom HTTP header. 如果發生這種情況, 伺服器會將要求處理為一般回傳, 這會導致用戶端錯誤。If this occurs, the server handles the request as a regular postback, which causes a client error. 若要解決此問題, 請在執行非同步貼文時插入自訂表格單域。To resolve this issue, insert a custom form field when you perform asynchronous posts. 然後檢查 [伺服器程式碼] 中的標頭或自訂表單欄位。Then check the header or the custom form field in server code.

UpdatePanel 使用方式UpdatePanel Usage

您可以使用多UpdatePanel個控制項來獨立更新多個頁面區域。You can use multiple UpdatePanel controls to update multiple page regions independently. 當包含一或多個UpdatePanel控制項的頁面第一次呈現時, 所有UpdatePanel控制項的所有內容都會轉譯並傳送至瀏覽器。When the page that contains one or more UpdatePanel controls is first rendered, all the content of all UpdatePanel controls are rendered and sent to the browser. 在後續的非同步回傳中, 每個UpdatePanel控制項的內容可能不會更新, 視面板設定以及個別面板的用戶端或伺服器邏輯而定。On subsequent asynchronous postbacks, the content of each UpdatePanel control might not be updated depending on the panel settings and on client or server logic for individual panels.

您也可以針對UpdatePanel下列各項使用控制項:You can also use UpdatePanel controls for the following:

  • 在使用者控制項中。In user controls.

  • 在 [主要] 和 [內容] 頁面上。On master and content pages.

  • 嵌套于其他UpdatePanel控制項中。Nested inside other UpdatePanel controls.

  • 在樣板化控制項 (例如GridViewRepeater控制項) 內。Inside templated controls such as the GridView or Repeater controls.

UpdatePanel控制項可以用宣告方式或以程式設計方式加入。UpdatePanel controls can be added declaratively or programmatically.

您可以用程式UpdatePanel設計方式加入控制項, 但無法以程式設計方式加入觸發程式。You can add an UpdatePanel control programmatically, but you cannot add triggers programmatically. 若要建立類似觸發程式的行為, 您可以在頁面上將控制項註冊為非同步回傳控制項。To create trigger-like behavior, you can register a control on the page as an asynchronous postback control. 您可以藉由呼叫RegisterAsyncPostBackControl ScriptManager控制項的方法來執行此動作。You do this by calling the RegisterAsyncPostBackControl method of the ScriptManager control. 接著, 您可以建立事件處理常式來執行以回應非同步回傳, 並在處理常式中呼叫Update UpdatePanel控制項的方法。You can then create an event handler that runs in response to the asynchronous postback, and in the handler, call the Update method of the UpdatePanel control.

套用樣式Applying Styles

UpdatePanel控制項接受 expando 屬性。The UpdatePanel control accepts expando attributes. 這可讓您為控制項所呈現的 HTML 專案設定 CSS 類別。This lets you set a CSS class for the HTML elements that the controls render. 例如, 您可以建立如下列範例所示的標記:For example, you might create the markup shown in the following example:

<asp:UpdatePanel runat="server" class="myStyle">  
</asp:UpdatePanel>   

上一個範例中的標記會在頁面執行時, 呈現與下列類似的 HTML:The markup in the previous example renders HTML similar to the following when the page runs:

<div id="ctl00_MainContent_UpdatePanel1" class="MyStyle">  
</div>  

宣告式語法Declarative Syntax

<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>  

建構函式

UpdatePanel()

初始化 UpdatePanel 類別的新執行個體。Initializes a new instance of the UpdatePanel class.

屬性

Adapter

針對控制項取得瀏覽器的特定配置器。Gets the browser-specific adapter for the control.

(繼承來源 Control)
AppRelativeTemplateSourceDirectory

取得或設定包含了此控制項之 PageUserControl 物件的相對應用程式虛擬目錄。Gets or sets the application-relative virtual directory of the Page or UserControl object that contains this control.

(繼承來源 Control)
Attributes

取得 UpdatePanel 控制項的階層式樣式表 (CSS) 屬性集合。Gets the cascading style sheet (CSS) attributes collection of the UpdatePanel control.

BindingContainer

取得包含了此控制項之資料繫結的控制項。Gets the control that contains this control's data binding.

(繼承來源 Control)
ChildControlsCreated

取得值,指出是否已經建立伺服器控制項的子控制項。Gets a value that indicates whether the server control's child controls have been created.

(繼承來源 Control)
ChildrenAsTriggers

取得或設定值,這個值表示來自 UpdatePanel 控制項之下層子控制項的回傳是否會更新面板內容。Gets or sets a value that indicates whether postbacks from immediate child controls of an UpdatePanel control update the panel's content.

ClientID

取得 ASP.NET 所產生之 HTML 標記的控制項識別碼。Gets the control ID for HTML markup that is generated by ASP.NET.

(繼承來源 Control)
ClientIDMode

取得或設定用來產生 ClientID 屬性值的演算法。Gets or sets the algorithm that is used to generate the value of the ClientID property.

(繼承來源 Control)
ClientIDSeparator

取得字元值,表示在 ClientID 屬性中所使用的分隔字元。Gets a character value representing the separator character used in the ClientID property.

(繼承來源 Control)
ContentTemplate

取得或設定用於定義 UpdatePanel 控制項內容的範本。Gets or sets the template that defines the content of the UpdatePanel control.

ContentTemplateContainer

取得的控制項物件可讓您以程式設計方式加入子控制項。Gets a control object to which you can programmatically add child controls.

Context

取得與目前 Web 要求的伺服器控制項關聯的 HttpContext 物件。Gets the HttpContext object associated with the server control for the current Web request.

(繼承來源 Control)
Controls

取得 ControlCollection 物件,其中包含 UpdatePanel 控制項的子控制項。Gets the ControlCollection object that contains the child controls for the UpdatePanel control.

DataItemContainer

如果命名容器實作 IDataItemContainer,則取得命名容器的參考。Gets a reference to the naming container if the naming container implements IDataItemContainer.

(繼承來源 Control)
DataKeysContainer

如果命名容器實作 IDataKeysControl,則取得命名容器的參考。Gets a reference to the naming container if the naming container implements IDataKeysControl.

(繼承來源 Control)
DesignMode

取得值,指出控制項是否正用於設計介面上。Gets a value indicating whether a control is being used on a design surface.

(繼承來源 Control)
EnableTheming

取得或設定值,指出佈景主題是否套用至此控制項。Gets or sets a value indicating whether themes apply to this control.

(繼承來源 Control)
EnableViewState

取得或設定值,該值表示伺服器控制項是否對要求的用戶端而言保持其檢視狀態,以及它包含的任何子控制項狀態。Gets or sets a value indicating whether the server control persists its view state, and the view state of any child controls it contains, to the requesting client.

(繼承來源 Control)
Events

取得控制項事件處理常式委派 (Delegate) 的清單。Gets a list of event handler delegates for the control. 這個屬性是唯讀的。This property is read-only.

(繼承來源 Control)
HasChildViewState

取得值,指出目前伺服器控制項的子控制項是否有任何已儲存的檢視狀態設定。Gets a value indicating whether the current server control's child controls have any saved view-state settings.

(繼承來源 Control)
ID

取得或設定指派給伺服器控制項的程式設計識別項。Gets or sets the programmatic identifier assigned to the server control.

(繼承來源 Control)
IdSeparator

取得用來分隔控制項識別項的字元。Gets the character used to separate control identifiers.

(繼承來源 Control)
IsChildControlStateCleared

取得值,指出這個控制項中所包含的控制項是否有控制項狀態。Gets a value indicating whether controls contained within this control have control state.

(繼承來源 Control)
IsInPartialRendering

取得值,這個值表示非同步回傳是否會導致更新 UpdatePanel 控制項。Gets a value that indicates whether the UpdatePanel control is being updated as a result of an asynchronous postback.

IsTrackingViewState

取得值,指出伺服器控制項是否正在儲存檢視狀態的變更。Gets a value that indicates whether the server control is saving changes to its view state.

(繼承來源 Control)
IsViewStateEnabled

取得值,指出這個控制項是否已啟用檢視狀態。Gets a value indicating whether view state is enabled for this control.

(繼承來源 Control)
LoadViewStateByID

取得值,指出控制項是否依 ID (而不是索引) 參與載入其檢視狀態。Gets a value indicating whether the control participates in loading its view state by ID instead of index.

(繼承來源 Control)
NamingContainer

取得伺服器控制項命名容器的參考,其建立唯一命名空間,在具有相同 ID 屬性值的伺服器控制項之間作區別。Gets a reference to the server control's naming container, which creates a unique namespace for differentiating between server controls with the same ID property value.

(繼承來源 Control)
Page

取得含有伺服器控制項的 Page 執行個體的參考。Gets a reference to the Page instance that contains the server control.

(繼承來源 Control)
Parent

在網頁控制階層架構中取得伺服器控制項之父控制項的參考。Gets a reference to the server control's parent control in the page control hierarchy.

(繼承來源 Control)
RenderingCompatibility

取得值,這個值會指定將與呈現 HTML 相容的 ASP.NET 版本。Gets a value that specifies the ASP.NET version that rendered HTML will be compatible with.

(繼承來源 Control)
RenderMode

取得或設定的值表示 UpdatePanel 控制項的內容是否包含在 HTML <div><span> 項目中。Gets or sets a value that indicates whether an UpdatePanel control's content is enclosed in an HTML <div> or <span> element.

RequiresUpdate

取得值,這個值表示是否會更新 UpdatePanel 控制項的內容。Gets a value that indicates whether the content of the UpdatePanel control will be updated.

Site

當呈現在設計介面上時,取得裝載目前控制項之容器的資訊。Gets information about the container that hosts the current control when rendered on a design surface.

(繼承來源 Control)
SkinID

取得或設定要套用至控制項的面板。Gets or sets the skin to apply to the control.

(繼承來源 Control)
TemplateControl

取得或設定包含了此控制項之樣板的參考。Gets or sets a reference to the template that contains this control.

(繼承來源 Control)
TemplateSourceDirectory

取得包含目前伺服器控制項的 PageUserControl 的虛擬目錄。Gets the virtual directory of the Page or UserControl that contains the current server control.

(繼承來源 Control)
Triggers

取得 UpdatePanelTriggerCollection 物件,這個物件包含 AsyncPostBackTriggerPostBackTrigger 物件 (針對 UpdatePanel 控制項以宣告方式註冊)。Gets an UpdatePanelTriggerCollection object that contains AsyncPostBackTrigger and PostBackTrigger objects that were registered declaratively for the UpdatePanel control.

UniqueID

取得伺服器控制項唯一的、符合階層架構的識別項。Gets the unique, hierarchically qualified identifier for the server control.

(繼承來源 Control)
UpdateMode

取得或設定值,這個值表示何時更新 UpdatePanel 控制項的內容。Gets or sets a value that indicates when an UpdatePanel control's content is updated.

ValidateRequestMode

取得或設定值,指出控制項是否對來自瀏覽器的用戶端輸入檢查潛在的危險值。Gets or sets a value that indicates whether the control checks client input from the browser for potentially dangerous values.

(繼承來源 Control)
ViewState

取得狀態資訊的字典,允許您在相同網頁的多個要求之間,儲存和還原伺服器控制項的檢視狀態。Gets a dictionary of state information that allows you to save and restore the view state of a server control across multiple requests for the same page.

(繼承來源 Control)
ViewStateIgnoresCase

取得值,指出 StateBag 物件是否不區分大小寫。Gets a value that indicates whether the StateBag object is case-insensitive.

(繼承來源 Control)
ViewStateMode

取得或設定這個控制項的檢視狀態模式。Gets or sets the view-state mode of this control.

(繼承來源 Control)
Visible

取得或設定值,指出伺服器控制項是否會轉譯為頁面上的 UI。Gets or sets a value that indicates whether a server control is rendered as UI on the page.

(繼承來源 Control)

方法

AddedControl(Control, Int32)

在子控制項加入 Control 物件的 Controls 集合後呼叫。Called after a child control is added to the Controls collection of the Control object.

(繼承來源 Control)
AddParsedSubObject(Object)

通知伺服器控制項,XML 或 HTML 項目已剖析,並將項目加入伺服器控制項的 ControlCollection 物件中。Notifies the server control that an element, either XML or HTML, was parsed, and adds the element to the server control's ControlCollection object.

(繼承來源 Control)
ApplyStyleSheetSkin(Page)

將頁面樣式表中所定義的樣式屬性套用至控制項。Applies the style properties defined in the page style sheet to the control.

(繼承來源 Control)
BeginRenderTracing(TextWriter, Object)

開始進行轉譯資料的設計階段追蹤。Begins design-time tracing of rendering data.

(繼承來源 Control)
BuildProfileTree(String, Boolean)

收集伺服器控制項的相關資訊,並在頁面啟用追蹤時將此資訊傳遞至 Trace 屬性以顯示之。Gathers information about the server control and delivers it to the Trace property to be displayed when tracing is enabled for the page.

(繼承來源 Control)
ClearCachedClientID()

將快取的 ClientID 值設定為 nullSets the cached ClientID value to null.

(繼承來源 Control)
ClearChildControlState()

刪除伺服器控制項之子控制項的控制項狀態資訊。Deletes the control-state information for the server control's child controls.

(繼承來源 Control)
ClearChildState()

刪除所有伺服器控制項之子控制項的檢視狀態和控制項狀態資訊。Deletes the view-state and control-state information for all the server control's child controls.

(繼承來源 Control)
ClearChildViewState()

刪除所有伺服器控制項之子控制項的檢視狀態資訊。Deletes the view-state information for all the server control's child controls.

(繼承來源 Control)
ClearEffectiveClientIDMode()

將目前的控制項執行個體和任何子控制項的 ClientIDMode 屬性設定為 InheritSets the ClientIDMode property of the current control instance and of any child controls to Inherit.

(繼承來源 Control)
CreateChildControls()

由 ASP.NET 網頁架構呼叫,通知使用組合實作的伺服器控制項來建立所包含的任何子控制項,以準備回傳或呈現。Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.

(繼承來源 Control)
CreateContentTemplateContainer()

建立 Control 物件,該物件是做為定義 UpdatePanel 控制項內容之子控制項的容器。Creates a Control object that acts as a container for child controls that define the UpdatePanel control's content.

CreateControlCollection()

傳回包含於 UpdatePanel 控制項之所有控制項的集合。Returns the collection of all controls contained in the UpdatePanel control.

DataBind()

將資料來源繫結至所叫用的伺服器控制項及其所有子控制項。Binds a data source to the invoked server control and all its child controls.

(繼承來源 Control)
DataBind(Boolean)

使用會引發 DataBinding 事件的選項,繫結資料來源至叫用的伺服器控制項及其所有子控制項。Binds a data source to the invoked server control and all its child controls with an option to raise the DataBinding event.

(繼承來源 Control)
DataBindChildren()

繫結資料來源至伺服器控制項的子控制項。Binds a data source to the server control's child controls.

(繼承來源 Control)
Dispose()

啟用伺服器控制項,在它從記憶體釋放之前執行最後清除。Enables a server control to perform final clean up before it is released from memory.

(繼承來源 Control)
EndRenderTracing(TextWriter, Object)

結束轉譯資料的設計階段追蹤。Ends design-time tracing of rendering data.

(繼承來源 Control)
EnsureChildControls()

判斷伺服器控制項是否包含子控制項。Determines whether the server control contains child controls. 如果不包含,則建立子控制項。If it does not, it creates child controls.

(繼承來源 Control)
EnsureID()

為尚未指定識別項的控制項,建立識別項。Creates an identifier for controls that do not have an identifier assigned.

(繼承來源 Control)
Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
FindControl(String)

在目前命名容器搜尋具有指定 id 參數的伺服器控制項。Searches the current naming container for a server control with the specified id parameter.

(繼承來源 Control)
FindControl(String, Int32)

使用指定的 id 和有助於搜尋之 pathOffset 參數中所指定的整數,在目前的命名容器中搜尋伺服器控制項。Searches the current naming container for a server control with the specified id and an integer, specified in the pathOffset parameter, which aids in the search. 您不應該覆寫這個版本的 FindControl 方法。You should not override this version of the FindControl method.

(繼承來源 Control)
Focus()

設定控制項的輸入焦點。Sets input focus to a control.

(繼承來源 Control)
GetDesignModeState()

取得控制項的設計階段資料。Gets design-time data for a control.

(繼承來源 Control)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetRouteUrl(Object)

取得會對應於一組路由參數的 URL。Gets the URL that corresponds to a set of route parameters.

(繼承來源 Control)
GetRouteUrl(RouteValueDictionary)

取得會對應於一組路由參數的 URL。Gets the URL that corresponds to a set of route parameters.

(繼承來源 Control)
GetRouteUrl(String, Object)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。Gets the URL that corresponds to a set of route parameters and a route name.

(繼承來源 Control)
GetRouteUrl(String, RouteValueDictionary)

取得 URL,此 URL 對應於一組路由參數及一個路由名稱。Gets the URL that corresponds to a set of route parameters and a route name.

(繼承來源 Control)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
GetUniqueIDRelativeTo(Control)

傳回指定之控制項 UniqueID 屬性的前置部分。Returns the prefixed portion of the UniqueID property of the specified control.

(繼承來源 Control)
HasControls()

判斷伺服器控制項是否包含任何子控制項。Determines if the server control contains any child controls.

(繼承來源 Control)
HasEvents()

傳回值,指出控制項或任何子控制項的事件是否已註冊。Returns a value indicating whether events are registered for the control or any child controls.

(繼承來源 Control)
Initialize()

如果已啟用部分網頁呈現,則初始化 UpdatePanel 控制項觸發程序集合。Initializes the UpdatePanel control trigger collection if partial-page rendering is enabled.

IsLiteralContent()

判斷伺服器控制項是否只儲存常值內容。Determines if the server control holds only literal content.

(繼承來源 Control)
LoadControlState(Object)

SaveControlState() 方法所儲存的上一頁要求中,還原控制項狀態資訊。Restores control-state information from a previous page request that was saved by the SaveControlState() method.

(繼承來源 Control)
LoadViewState(Object)

SaveViewState() 方法所儲存的先前頁面要求來還原檢視狀態資訊。Restores view-state information from a previous page request that was saved by the SaveViewState() method.

(繼承來源 Control)
MapPathSecure(String)

擷取虛擬絕對路徑或相對路徑所對應至的實體路徑。Retrieves the physical path that a virtual path, either absolute or relative, maps to.

(繼承來源 Control)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
OnBubbleEvent(Object, EventArgs)

決定伺服器控制項的事件是否要在頁面的 UI 伺服器控制項階層架構中向上傳遞。Determines whether the event for the server control is passed up the page's UI server control hierarchy.

(繼承來源 Control)
OnDataBinding(EventArgs)

引發 DataBinding 事件。Raises the DataBinding event.

(繼承來源 Control)
OnInit(EventArgs)

引發 Init 事件。Raises the Init event.

OnLoad(EventArgs)

在未啟用部分網頁呈現的情況下,引發 Load 控制項的 UpdatePanel 事件,並叫用 Initialize() 方法。Raises the Load event for the UpdatePanel control and invokes the Initialize() method when partial-page rendering is not enabled.

OnPreRender(EventArgs)

引發 PreRender 事件。Raises the PreRender event.

OnUnload(EventArgs)

引發基底 Unload 事件。Raises the base Unload event.

OpenFile(String)

取得用來讀取檔案的 StreamGets a Stream used to read a file.

(繼承來源 Control)
RaiseBubbleEvent(Object, EventArgs)

指派事件的任何來源和它的資訊至控制項的父控制項。Assigns any sources of the event and its information to the control's parent.

(繼承來源 Control)
RemovedControl(Control)

Control 物件的 Controls 集合中移除子控制項之後呼叫。Called after a child control is removed from the Controls collection of the Control object.

(繼承來源 Control)
Render(HtmlTextWriter)

引發 Render(HtmlTextWriter) 事件。Raises the Render(HtmlTextWriter) event.

RenderChildren(HtmlTextWriter)

引發 RenderChildren(HtmlTextWriter) 事件。Raises the RenderChildren(HtmlTextWriter) event.

RenderControl(HtmlTextWriter)

將伺服器控制項內容輸出至提供的 HtmlTextWriter 物件,並在啟用追蹤時儲存控制項的追蹤資訊。Outputs server control content to a provided HtmlTextWriter object and stores tracing information about the control if tracing is enabled.

(繼承來源 Control)
RenderControl(HtmlTextWriter, ControlAdapter)

使用提供的 HtmlTextWriter 物件,輸出伺服器控制項內容至提供的 ControlAdapter 物件。Outputs server control content to a provided HtmlTextWriter object using a provided ControlAdapter object.

(繼承來源 Control)
ResolveAdapter()

取得負責呈現指定之控制項的控制項配置器。Gets the control adapter responsible for rendering the specified control.

(繼承來源 Control)
ResolveClientUrl(String)

取得瀏覽器可使用的 URL。Gets a URL that can be used by the browser.

(繼承來源 Control)
ResolveUrl(String)

將 URL 轉換為要求用戶端可使用的 URL。Converts a URL into one that is usable on the requesting client.

(繼承來源 Control)
SaveControlState()

儲存頁面回傳至伺服器以來,所發生的任何伺服器控制項狀態變更。Saves any server control state changes that have occurred since the time the page was posted back to the server.

(繼承來源 Control)
SaveViewState()

儲存自頁面回傳至伺服器以來所發生的任何伺服器控制項檢視狀態變更。Saves any server control view-state changes that have occurred since the time the page was posted back to the server.

(繼承來源 Control)
SetDesignModeState(IDictionary)

設定控制項的設計階段資料。Sets design-time data for a control.

(繼承來源 Control)
SetRenderMethodDelegate(RenderMethod)

指定事件處理常式委派,以呈現伺服器控制項及其內容至其父控制項。Assigns an event handler delegate to render the server control and its content into its parent control.

(繼承來源 Control)
SetTraceData(Object, Object)

使用追蹤資料機碼和追蹤資料值,設定設計階段期間追蹤呈現資料的追蹤資料。Sets trace data for design-time tracing of rendering data, using the trace data key and the trace data value.

(繼承來源 Control)
SetTraceData(Object, Object, Object)

使用追蹤的物體、追蹤資料機碼和追蹤資料值,設定設計階段期間追蹤呈現資料的追蹤資料。Sets trace data for design-time tracing of rendering data, using the traced object, the trace data key, and the trace data value.

(繼承來源 Control)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
TrackViewState()

導致對伺服器控制項的檢視狀態變更的追蹤 (Tracking),以便它們能夠儲存於伺服器控制項的 StateBag 物件。Causes tracking of view-state changes to the server control so they can be stored in the server control's StateBag object. 這個物件可透過 ViewState 屬性存取。This object is accessible through the ViewState property.

(繼承來源 Control)
Update()

導致更新 UpdatePanel 控制項的內容。Causes an update of the content of an UpdatePanel control.

事件

DataBinding

發生於伺服器控制項繫結至資料來源時。Occurs when the server control binds to a data source.

(繼承來源 Control)
Disposed

發生於伺服器控制項從記憶體釋放時,這是在要求 ASP.NET 網頁時,伺服器控制項生命週期的最後階段。Occurs when a server control is released from memory, which is the last stage of the server control lifecycle when an ASP.NET page is requested.

(繼承來源 Control)
Init

發生於初始化伺服器控制項時,是其生命週期中的第一個步驟。Occurs when the server control is initialized, which is the first step in its lifecycle.

(繼承來源 Control)
Load

發生於載入伺服器控制項至 Page 物件時。Occurs when the server control is loaded into the Page object.

(繼承來源 Control)
PreRender

Control 物件載入之後但在呈現之前發生。Occurs after the Control object is loaded but prior to rendering.

(繼承來源 Control)
Unload

發生於伺服器控制項從記憶體卸載時。Occurs when the server control is unloaded from memory.

(繼承來源 Control)

明確介面實作

IAttributeAccessor.GetAttribute(String)

使用指定的名稱,傳回 Web 控制項的屬性。Returns an attribute of a Web control by using a specified name.

IAttributeAccessor.SetAttribute(String, String)

設定指定之控制項屬性的值。Sets the value of the specified control attribute.

IControlBuilderAccessor.ControlBuilder

如需這個成員的說明,請參閱 ControlBuilderFor a description of this member, see ControlBuilder.

(繼承來源 Control)
IControlDesignerAccessor.GetDesignModeState()

如需這個成員的說明,請參閱 GetDesignModeState()For a description of this member, see GetDesignModeState().

(繼承來源 Control)
IControlDesignerAccessor.SetDesignModeState(IDictionary)

如需這個成員的說明,請參閱 SetDesignModeState(IDictionary)For a description of this member, see SetDesignModeState(IDictionary).

(繼承來源 Control)
IControlDesignerAccessor.SetOwnerControl(Control)

如需這個成員的說明,請參閱 SetOwnerControl(Control)For a description of this member, see SetOwnerControl(Control).

(繼承來源 Control)
IControlDesignerAccessor.UserData

如需這個成員的說明,請參閱 UserDataFor a description of this member, see UserData.

(繼承來源 Control)
IDataBindingsAccessor.DataBindings

如需這個成員的說明,請參閱 DataBindingsFor a description of this member, see DataBindings.

(繼承來源 Control)
IDataBindingsAccessor.HasDataBindings

如需這個成員的說明,請參閱 HasDataBindingsFor a description of this member, see HasDataBindings.

(繼承來源 Control)
IExpressionsAccessor.Expressions

如需這個成員的說明,請參閱 ExpressionsFor a description of this member, see Expressions.

(繼承來源 Control)
IExpressionsAccessor.HasExpressions

如需這個成員的說明,請參閱 HasExpressionsFor a description of this member, see HasExpressions.

(繼承來源 Control)
IParserAccessor.AddParsedSubObject(Object)

如需這個成員的說明,請參閱 AddParsedSubObject(Object)For a description of this member, see AddParsedSubObject(Object).

(繼承來源 Control)

擴充方法

FindDataSourceControl(Control)

傳回與指定之控制項的資料控制項相關聯的資料來源。Returns the data source that is associated with the data control for the specified control.

FindFieldTemplate(Control, String)

傳回在指定之控制項的命名容器中所指定資料行的欄位樣板。Returns the field template for the specified column in the specified control's naming container.

FindMetaTable(Control)

傳回包含資料控制項的中繼資料表物件。Returns the metatable object for the containing data control.

適用於

另請參閱