HtmlControl.SetAttribute(String, String) Method

Definition

Sets the value of the named attribute on the HtmlControl control.

C#
protected virtual void SetAttribute(string name, string value);

Parameters

name
String

The name of the attribute to set.

value
String

The value to set the attribute to.

Remarks

Use the SetAttribute method to set an attribute on the HtmlControl server control. All HTML server controls store their attributes in the Control.ViewState property.

HTML attributes are treated by the ASP.NET page framework as properties on the HTML server control to which they belong. The SetAttribute method's name parameter is case-insensitive.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also