UserControl 類別

定義

代表 .ascx 檔案,也稱為使用者控制項,由裝載 ASP.NET Web 應用程式的伺服器提出要求。Represents an .ascx file, also known as a user control, requested from a server that hosts an ASP.NET Web application. 檔案必須從 Web Form 網頁呼叫,否則會發生剖析器 (Parser) 錯誤。The file must be called from a Web Forms page or a parser error will occur.

public ref class UserControl : System::Web::UI::TemplateControl, System::Web::UI::IAttributeAccessor, System::Web::UI::IUserControlDesignerAccessor
public class UserControl : System.Web.UI.TemplateControl, System.Web.UI.IAttributeAccessor, System.Web.UI.IUserControlDesignerAccessor
type UserControl = class
    inherit TemplateControl
    interface IAttributeAccessor
    interface INamingContainer
    interface IUserControlDesignerAccessor
Public Class UserControl
Inherits TemplateControl
Implements IAttributeAccessor, IUserControlDesignerAccessor
繼承
衍生
實作

範例

在下列範例SimpleControl中定義的類別會UserControl繼承類別,而且可以當做 ASP.NET 程式碼後置類別使用。The class defined in the following example, SimpleControl, inherits the UserControl class and can be used as an ASP.NET code-behind class. 它會使用TextBoxLabel myButton_Click和 Web 服務器Label.Text控制項,並定義將屬性值和兩個字串指派給屬性的方法。TextBox.Text ButtonIt uses the TextBox, Label, and Button Web server controls and defines a myButton_Click method that assigns the TextBox.Text property value, along with two strings, to the Label.Text property.

重要

這個範例有一個可接受使用者輸入的文字方塊,這可能會造成安全性威脅。This example has a text box that accepts user input, which is a potential security threat. 根據預設,ASP.NET Web 網頁會驗證使用者輸入未包含指令碼或 HTML 項目。By default, ASP.NET Web pages validate that user input does not include script or HTML elements. 如需詳細資訊,請參閱 Script Exploits Overview (指令碼攻擊概觀)。For more information, see Script Exploits Overview.

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

public class SimpleControl:UserControl
{

  public TextBox name;
  public Label output;
  public Button myButton;

  public void myButton_Click(object sender, EventArgs e)
  { 
    output.Text = "Hello, " + name.Text + ".";

  }
 
}
Imports System.Web.UI
Imports System.Web.UI.WebControls


Public Class SimpleControl
   Inherits UserControl
   Public name As TextBox
   Public output As Label
   Public myButton As Button
   
   
   Public Sub myButton_Click(sender As Object, e As EventArgs)

      output.Text = "Hello, " + name.Text + "."

   End Sub  

End Class

下列範例是包含在 .ascx 檔案中的標記。The following example is markup contained in an .ascx file. 您可以使用上SimpleControl一個範例中定義的類別,做為這個 .ascx 檔案中標記的程式碼後置類別。You can use the SimpleControl class defined in the previous example as a code-behind class for the markup in this .ascx file.

<%@ control inherits = "SimpleControl" src = "SimpleControl.cs" %>

<table style="background-color:yellow;font: 10pt verdana;border-width:1;border-style:solid;border-color:black;" cellspacing="15">
<tr>
<td><b>Enter your name here: </b></td>
<td><ASP:TextBox id="name" runat="server"/></td>
</tr>
<tr>
<td><b><ASP:Label id="output" runat="server"/></b></td>
</tr>
<tr>
<td></td>
<td><asp:button id="myButton" text="Submit" OnClick="myButton_Click" runat="server" /></td>
</tr>
</table>
<%@ control inherits = "SimpleControl" src = "SimpleControl.vb" %>

<table style="background-color: yellow; font: 10pt verdana;border-width:1;border-style:solid;border-color:black;" cellspacing="15">
<tr>
<td><b>Enter your name here: </b></td>
<td><ASP:TextBox id="name" runat="server"/></td>
</tr>
<tr>
<td><b><ASP:Label id="output" runat="server"/></b></td>
</tr>
<tr>
<td></td>
<td><asp:button text="Submit" OnClick="myButton_Click" runat="server" /></td>
</tr>
</table>

備註

UserControl類別與副檔名為 .ascx 的檔案相關聯。The UserControl class is associated with files that have .ascx extensions. 這些檔案會在執行時間編譯成UserControl物件,並在伺服器記憶體中快取。These files are compiled at run time as UserControl objects and cached in server memory.

您可以藉由宣告另一個 .ascx 檔案(在 Web form 頁面中包含後者)來嵌套使用者控制項。You can nest user controls by declaring one .ascx file in another including the latter in a Web Forms page.

使用者控制項包含在 ASP.NET Web form 頁面中,並提供 Web 開發人員簡單的方式來捕捉常用的 Web UI。User controls are contained in ASP.NET Web Forms pages, and offer Web developers an easy way to capture commonly used Web UI. 它們會以類似Page物件的方式具現化和快取。They are instantiated and cached in ways similar to Page objects. 不過,與頁面不同的是,使用者控制項無法獨立呼叫。Unlike pages, however, user controls cannot be called independently. 只能從頁面或包含它們的其他使用者控制項呼叫它們。They can only be called from the page or other user control that contains them.

如果您想要使用程式碼後置技術來建立使用者控制項,請從這個類別衍生。Derive from this class if you want to create a user control using the code-behind technique. 如果您要使用這項技術來開發 Web form 頁面,建議您使用此選項。This is recommended if you are developing Web Forms pages using this technique.

如需以宣告方式建立使用者控制項的詳細資訊,請參閱ASP.NET 使用者控制項For information about creating user controls declaratively, see ASP.NET User Controls.

建構函式

UserControl()

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

屬性

Adapter

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

(繼承來源 Control)
Application

取得目前 Web 要求的 Application 物件。Gets the Application object for the current Web request.

AppRelativeTemplateSourceDirectory

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

(繼承來源 Control)
AppRelativeVirtualPath

取得或設定要在其中剖析和編譯控制項之檔案的應用程式相對虛擬目錄路徑。Gets or sets the application-relative, virtual directory path to the file from which the control is parsed and compiled.

(繼承來源 TemplateControl)
Attributes

取得 .aspx 檔案內的使用者控制項標記中所宣告的所有屬性 (Attribute) 名稱和值配對的集合。Gets a collection of all attribute name and value pairs declared in the user control tag within the .aspx file.

AutoHandlers

AutoHandlers 屬性在 ASP.NET 2.0 中已被取代。The AutoHandlers property has been deprecated in ASP.NET NET 2.0. 此屬性由產生的類別使用,並不適用於您的程式碼中。It is used by generated classes and is not intended for use within your code.

(繼承來源 TemplateControl)
BindingContainer

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

(繼承來源 Control)
Cache

取得 Cache 物件,這個物件與包含使用者控制項的應用程式關聯。Gets the Cache object that is associated with the application that contains the user control.

CachePolicy

取得這個使用者控制項之快取參數集合的參考。Gets a reference to a collection of caching parameters for this user control.

ChildControlsCreated

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

(繼承來源 Control)
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)
Context

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

(繼承來源 Control)
Controls

取得 ControlCollection 物件,表示 UI 階層架構中指定之伺服器控制項的子控制項。Gets a ControlCollection object that represents the child controls for a specified server control in the UI hierarchy.

(繼承來源 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

取得或設定布林值,指出主題是否套用至衍生自 TemplateControl 類別的控制項。Gets or sets a Boolean value indicating whether themes apply to the control that is derived from the TemplateControl class.

(繼承來源 TemplateControl)
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)
IsPostBack

取得值,指出使用者控制項是否為回應用戶端回傳而被載入,或者是否為第一次被載入與存取。Gets a value indicating whether the user control is being loaded in response to a client postback, or if it is being loaded and accessed for the first time.

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

取得目前 Web 要求的 HttpRequest 物件。Gets the HttpRequest object for the current Web request.

Response

取得目前 Web 要求的 HttpResponse 物件。Gets the HttpResponse object for the current Web request.

Server

取得目前 Web 要求的 HttpServerUtility 物件。Gets the HttpServerUtility object for the current Web request.

Session

取得目前 Web 要求的 HttpSessionState 物件。Gets the HttpSessionState object for the current Web request.

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

取得值,指出 TemplateControl 控制項是否支援自動事件。Gets a value indicating whether the TemplateControl control supports automatic events.

(繼承來源 TemplateControl)
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)
Trace

取得目前 Web 要求的 TraceContext 物件。Gets the TraceContext object for the current Web request.

UniqueID

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

(繼承來源 Control)
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)
Construct()

執行設計階段邏輯。Performs design-time logic.

(繼承來源 TemplateControl)
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)
CreateControlCollection()

建立新的 ControlCollection 物件來保存伺服器控制項的子控制項 (常值和伺服器)。Creates a new ControlCollection object to hold the child controls (both literal and server) of the server control.

(繼承來源 Control)
CreateResourceBasedLiteralControl(Int32, Int32, Boolean)

存取儲存在資源中的常值字串。Accesses literal strings stored in a resource. CreateResourceBasedLiteralControl(Int32, Int32, Boolean) 方法並不適合從您的程式碼使用。The CreateResourceBasedLiteralControl(Int32, Int32, Boolean) method is not intended for use from within your code.

(繼承來源 TemplateControl)
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)
DesignerInitialize()

在 RAD 設計工具需要的使用者控制項上,執行任何初始步驟。Performs any initialization steps on the user control that are required by RAD designers.

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)
Eval(String)

評估資料繫結運算式。Evaluates a data-binding expression.

(繼承來源 TemplateControl)
Eval(String, String)

使用指定的格式字串評估資料繫結運算式以顯示結果。Evaluates a data-binding expression using the specified format string to display the result.

(繼承來源 TemplateControl)
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)
FrameworkInitialize()

初始化衍生自 TemplateControl 類別的控制項。Initializes the control that is derived from the TemplateControl class.

(繼承來源 TemplateControl)
GetDesignModeState()

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

(繼承來源 Control)
GetGlobalResourceObject(String, String)

根據指定的 ClassKeyResourceKey 屬性,取得應用程式層級資源物件。Gets an application-level resource object based on the specified ClassKey and ResourceKey properties.

(繼承來源 TemplateControl)
GetGlobalResourceObject(String, String, Type, String)

根據指定的 ClassKeyResourceKey 屬性、物件型別和資源的屬性名稱,取得應用程式層級資源物件。Gets an application-level resource object based on the specified ClassKey and ResourceKey properties, object type, and property name of the resource.

(繼承來源 TemplateControl)
GetHashCode()

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

(繼承來源 Object)
GetLocalResourceObject(String)

根據指定的 ResourceKey 屬性,取得頁面層級資源物件。Gets a page-level resource object based on the specified ResourceKey property.

(繼承來源 TemplateControl)
GetLocalResourceObject(String, Type, String)

根據指定的 ResourceKey 屬性、物件型別和屬性名稱,取得頁面層級資源物件。Gets a page-level resource object based on the specified ResourceKey property, object type, and property name.

(繼承來源 TemplateControl)
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)
InitializeAsUserControl(Page)

初始化已經宣告地建立的 UserControl 物件。Initializes the UserControl object that has been created declaratively. 因為在網頁和使用者控制項之間有一些差異,這個方法確定使用者控制項會適當的初始化。Since there are some differences between pages and user controls, this method makes sure that the user control is initialized properly.

IsLiteralContent()

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

(繼承來源 Control)
LoadControl(String)

根據指定的虛擬路徑,從檔案載入 Control 物件。Loads a Control object from a file based on a specified virtual path.

(繼承來源 TemplateControl)
LoadControl(Type, Object[])

根據指定的型別和建構函式參數,載入 Control 物件。Loads a Control object based on a specified type and constructor parameters.

(繼承來源 TemplateControl)
LoadControlState(Object)

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

(繼承來源 Control)
LoadTemplate(String)

從外部檔案取得 ITemplate 介面的執行個體。Obtains an instance of the ITemplate interface from an external file.

(繼承來源 TemplateControl)
LoadViewState(Object)

SaveViewState() 方法所儲存的先前使用者控制項要求來還原檢視狀態資訊。Restores the view-state information from a previous user control request that was saved by the SaveViewState() method.

MapPath(String)

將虛擬的檔案路徑 (絕對或相對) 指派給實體檔案路徑。Assigns a virtual file path, either absolute or relative, to a physical file path.

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)
OnAbortTransaction(EventArgs)

引發 AbortTransaction 事件。Raises the AbortTransaction event.

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

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

(繼承來源 Control)
OnCommitTransaction(EventArgs)

引發 CommitTransaction 事件。Raises the CommitTransaction event.

(繼承來源 TemplateControl)
OnDataBinding(EventArgs)

引發 DataBinding 事件。Raises the DataBinding event.

(繼承來源 Control)
OnError(EventArgs)

引發 Error 事件。Raises the Error event.

(繼承來源 TemplateControl)
OnInit(EventArgs)

引發 Init 事件。Raises the Init event.

OnLoad(EventArgs)

引發 Load 事件。Raises the Load event.

(繼承來源 Control)
OnPreRender(EventArgs)

引發 PreRender 事件。Raises the PreRender event.

(繼承來源 Control)
OnUnload(EventArgs)

引發 Unload 事件。Raises the Unload event.

(繼承來源 Control)
OpenFile(String)

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

(繼承來源 Control)
ParseControl(String)

在 Web Form 網頁或使用者控制項上,將輸入字串剖析為 Control 物件。Parses an input string into a Control object on the Web Forms page or user control.

(繼承來源 TemplateControl)
ParseControl(String, Boolean)

在 ASP.NET 網頁或使用者控制項上,將輸入字串剖析為 Control 物件。Parses an input string into a Control object on the ASP.NET Web page or user control.

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

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

(繼承來源 Control)
ReadStringResource()

讀取字串資源。Reads a string resource. ReadStringResource() 方法並不適合從您的程式碼使用。The ReadStringResource() method is not intended for use from within your code.

(繼承來源 TemplateControl)
RemovedControl(Control)

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

(繼承來源 Control)
Render(HtmlTextWriter)

將伺服器控制項內容傳送到提供的 HtmlTextWriter 物件,以寫入要在用戶端上呈現的內容。Sends server control content to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(繼承來源 Control)
RenderChildren(HtmlTextWriter)

輸出伺服器控制項之子控制項的內容至提供的 HtmlTextWriter 物件,這個物件會寫入用戶端上所要呈現的內容。Outputs the content of a server control's children to a provided HtmlTextWriter object, which writes the content to be rendered on the client.

(繼承來源 Control)
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 user control view-state changes that have occurred since the last page postback.

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)
SetStringResourcePointer(Object, Int32)

設定字串資源的指標。Sets a pointer to a string resource. SetStringResourcePointer(Object, Int32) 方法由產生的類別使用,並不適合從您的程式碼使用。The SetStringResourcePointer(Object, Int32) method is used by generated classes and is not intended for use from within your code.

(繼承來源 TemplateControl)
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)
TestDeviceFilter(String)

傳回布林值,指出裝置篩選條件是否套用至 HTTP 要求。Returns a Boolean value indicating whether a device filter applies to the HTTP request.

(繼承來源 TemplateControl)
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)
TryUpdateModel<TModel>(TModel)

嘗試使用資料繫結控制項的值來更新模型執行個體。Attempts to update the model instance by using the values from the data-bound control.

TryUpdateModel<TModel>(TModel, IValueProvider)

嘗試使用來自值提供者的值更新模型執行個體。Attempts to update the model instance using values from the value provider.

UpdateModel<TModel>(TModel)

使用資料繫結控制項的值來更新模型執行個體。Updates the model instance by using values from the data-bound control.

UpdateModel<TModel>(TModel, IValueProvider)

使用來自使用者控制項之值提供者的值,更新指定的模型執行個體。Updates the specified model instance using values from the value provider of the user control.

WriteUTF8ResourceString(HtmlTextWriter, Int32, Int32, Boolean)

將資源字串寫入 HtmlTextWriter 控制項。Writes a resource string to an HtmlTextWriter control. WriteUTF8ResourceString(HtmlTextWriter, Int32, Int32, Boolean) 方法由產生的類別使用,並不適合從您的程式碼使用。The WriteUTF8ResourceString(HtmlTextWriter, Int32, Int32, Boolean) method is used by generated classes and is not intended for use from within your code.

(繼承來源 TemplateControl)
XPath(String)

評估 XPath 資料繫結運算式。Evaluates an XPath data-binding expression.

(繼承來源 TemplateControl)
XPath(String, IXmlNamespaceResolver)

使用命名空間解析所需之指定的前置詞和命名空間對應,評估 XPath 資料繫結運算式。Evaluates an XPath data-binding expression using the specified prefix and namespace mappings for namespace resolution.

(繼承來源 TemplateControl)
XPath(String, String)

使用指定的格式字串評估 XPath 資料繫結運算式以顯示結果。Evaluates an XPath data-binding expression using the specified format string to display the result.

(繼承來源 TemplateControl)
XPath(String, String, IXmlNamespaceResolver)

使用命名空間解析所需之指定的前置詞和命名空間對應,以及指定的格式字串,評估 XPath 資料繫結運算式以顯示結果。Evaluates an XPath data-binding expression using the specified prefix and namespace mappings for namespace resolution and the specified format string to display the result.

(繼承來源 TemplateControl)
XPathSelect(String)

評估 XPath 資料繫結運算式,並傳回可以實作 IEnumerable 介面的節點集合。Evaluates an XPath data-binding expression and returns a node collection that implements the IEnumerable interface.

(繼承來源 TemplateControl)
XPathSelect(String, IXmlNamespaceResolver)

使用命名空間解析所需之指定的前置詞和命名空間對應,評估 XPath 資料繫結運算式,並傳回實作 IEnumerable 介面的節點集合。Evaluates an XPath data-binding expression using the specified prefix and namespace mappings for namespace resolution and returns a node collection that implements the IEnumerable interface.

(繼承來源 TemplateControl)

事件

AbortTransaction

在使用者結束交易時發生。Occurs when a user ends a transaction.

(繼承來源 TemplateControl)
CommitTransaction

當交易完成時發生。Occurs when a transaction completes.

(繼承來源 TemplateControl)
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)
Error

當擲回未處理的例外狀況時發生。Occurs when an unhandled exception is thrown.

(繼承來源 TemplateControl)
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)

傳回指定之使用者控制項屬性的值。Returns the value of the specified user control attribute.

IAttributeAccessor.SetAttribute(String, String)

設定指定之使用者控制項屬性的值。Sets the value of the specified user 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)
IFilterResolutionService.CompareFilters(String, String)

傳回值,指出兩個指定的裝置篩選條件之間是否存在父子式關聯性。Returns a value that indicates whether a parent/child relationship exists between two specified device filters.

(繼承來源 TemplateControl)
IFilterResolutionService.EvaluateFilter(String)

傳回值,指出指定的篩選條件是否為目前篩選條件物件的類型。Returns a value that indicates whether the specified filter is a type of the current filter object.

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

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

(繼承來源 Control)
IUserControlDesignerAccessor.InnerText

取得或設定出現在使用者控制項的開頭和結尾標記之間的文字。Gets or sets the text that appears between the opening and closing tags of a user control.

IUserControlDesignerAccessor.TagName

取得或設定使用者控制項的完整標記名稱。Gets or sets the full tag name of the user 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.

GetDefaultValues(INamingContainer)

取得所指定資料控制項的預設值集合。Gets the collection of the default values for the specified data control.

GetMetaTable(INamingContainer)

取得所指定資料控制項中的資料表中繼資料。Gets the table metadata for the specified data control.

SetMetaTable(INamingContainer, MetaTable)

設定所指定資料控制項中的資料表中繼資料。Sets the table metadata for the specified data control.

SetMetaTable(INamingContainer, MetaTable, IDictionary<String,Object>)

設定所指定資料控制項的資料表中繼資料及預設值對應。Sets the table metadata and default value mapping for the specified data control.

SetMetaTable(INamingContainer, MetaTable, Object)

設定所指定資料控制項的資料表中繼資料及預設值對應。Sets the table metadata and default value mapping for the specified data control.

TryGetMetaTable(INamingContainer, MetaTable)

判斷資料表中繼資料是否可供使用。Determines whether table metadata is available.

EnableDynamicData(INamingContainer, Type)

針對指定的資料控制項啟用動態資料行為。Enables Dynamic Data behavior for the specified data control.

EnableDynamicData(INamingContainer, Type, IDictionary<String,Object>)

針對指定的資料控制項啟用動態資料行為。Enables Dynamic Data behavior for the specified data control.

EnableDynamicData(INamingContainer, Type, Object)

針對指定的資料控制項啟用動態資料行為。Enables Dynamic Data behavior for the specified data control.

適用於

另請參閱