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 库依赖项。

该方法 RegisterExpandoAttribute 将名称/值对注册为指定控件的自定义属性。 属性从 ECMAScript (JavaScript) 动态设置,以保留呈现控件标记的 XHTML 兼容性。 如果必须转义动态属性值中的任何字符,则设置为

如果未找到要向其添加动态属性的控件,则会发生脚本错误。

适用于

另请参阅