System.Web.UI.HtmlTextWriter.AddAttribute Method

Adds the specified markup attribute and value to the opening tag of the element that the System.Web.UI.HtmlTextWriter object creates with a subsequent call to the erload:System.Web.UI.HtmlTextWriter.RenderBeginTag method.

Syntax

public virtual void AddAttribute (string name, string value)

Parameters

name
A string containing the name of the attribute to add.
value
A string containing the value to assign to the attribute.

Remarks

Use the HtmlTextWriter.AddAttribute(string, string) overload of the HtmlTextWriter.AddAttribute(string, string) method if the attribute is not one of the System.Web.UI.HtmlTextWriterAttribute values, or if the attribute is not known until run time.

For an instance of any given markup element, the System.Web.UI.HtmlTextWriter class maintains a list of attributes for that element. When the erload:System.Web.UI.HtmlTextWriter.RenderBeginTag method is called, any attributes added by the erload:System.Web.UI.HtmlTextWriter.AddAttribute method are rendered to the opening tag of the element. The list of attributes is then cleared from the System.Web.UI.HtmlTextWriter object.

The coding pattern for rendering markup elements is as follows:

Requirements

Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0