編輯

共用方式為


ScriptManager.RegisterExpandoAttribute Method

Definition

Registers a name/value pair with the ScriptManager control as a custom (expando) attribute of a specified control.

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)

Parameters

control
Control

The control that is registering the expando attribute.

controlId
String

The control that contains the custom attribute on the page.

attributeName
String

The name of the custom attribute to register.

attributeValue
String

The value of the custom attribute.

encode
Boolean

true to encode the custom attribute that is being registered; otherwise, false.

Exceptions

control is null.

control is not in the page's control tree.

-or-

controlId is null.

-or-

controlId is empty.

-or-

attributeName is null.

-or-

attributeName is empty.

-or-

attributeName is already registered.

Remarks

You use the RegisterExpandoAttribute method to register a custom (expando) property for a control that is compatible with partial-page rendering and that has no Microsoft Ajax Library dependencies.

The RegisterExpandoAttribute method registers a name/value pair as a custom attribute for the specified control. The property is set dynamically from ECMAScript (JavaScript) to preserve XHTML compatibility for the rendered control's markup. Set encode to true if you have to escape any characters in the dynamic property's value.

If the control to which the dynamic property will be added is not found, a script error occurs.

Applies to

See also