共用方式為


ScriptManager.RegisterExpandoAttribute 方法

定義

使用 ScriptManager 控制項,將名稱/值組註冊為指定之控制項的自訂 (expando) 屬性。

public:
 static void RegisterExpandoAttribute(System::Web::UI::Control ^ control, System::String ^ controlId, System::String ^ attributeName, System::String ^ attributeValue, bool encode);
public static void RegisterExpandoAttribute (System.Web.UI.Control control, string controlId, string attributeName, string attributeValue, bool encode);
static member RegisterExpandoAttribute : System.Web.UI.Control * string * string * string * bool -> unit
Public Shared Sub RegisterExpandoAttribute (control As Control, controlId As String, attributeName As String, attributeValue As String, encode As Boolean)

參數

control
Control

要註冊 expando 屬性的控制項。

controlId
String

網頁上包含自訂屬性的控制項。

attributeName
String

要註冊的自訂屬性名稱。

attributeValue
String

自訂屬性的值。

encode
Boolean

true 表示為所要註冊的自訂屬性編碼,否則為 false

例外狀況

controlnull

control 不在網頁的控制項樹狀結構中。

-或- controlIdnull

-或- controlId 是空的。

-或- attributeNamenull

-或- attributeName 是空的。

-或- attributeName 已註冊。

備註

您可以使用 RegisterExpandoAttribute 方法來為與部分頁面轉譯相容的控制項註冊自訂 (expando) 屬性,而且沒有 Microsoft Ajax Library 相依性。

方法 RegisterExpandoAttribute 會將名稱/值組註冊為指定控制項的自訂屬性。 屬性會從 ECMAScript (JavaScript) 動態設定,以保留轉譯控制項標記的 XHTML 相容性。 true如果您必須逸出動態屬性值中的任何字元,請將 設定 encode 為 。

如果找不到將新增動態屬性的控制項,就會發生腳本錯誤。

適用於

另請參閱