ScriptManager.RegisterExpandoAttribute 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
使用 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
。
例外狀況
control
為 null
。
control
不在網頁的控制項樹狀結構中。
-或-
controlId
為 null
。
-或-
controlId
是空的。
-或-
attributeName
為 null
。
-或-
attributeName
是空的。
-或-
attributeName
已註冊。
備註
您可以使用 RegisterExpandoAttribute 方法來為與部分頁面轉譯相容的控制項註冊自訂 (expando) 屬性,而且沒有 Microsoft Ajax Library 相依性。
方法 RegisterExpandoAttribute 會將名稱/值組註冊為指定控制項的自訂屬性。 屬性會從 ECMAScript (JavaScript) 動態設定,以保留轉譯控制項標記的 XHTML 相容性。 true
如果您必須逸出動態屬性值中的任何字元,請將 設定 encode
為 。
如果找不到將新增動態屬性的控制項,就會發生腳本錯誤。