Adds the markup attribute and the attribute 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.
- key
- An System.Web.UI.HtmlTextWriterAttribute that represents the markup attribute to add to the output stream.
- value
- A string containing the value to assign to the attribute.
Use the HtmlTextWriter.AddAttribute(HtmlTextWriterAttribute, string) overload of the HtmlTextWriter.AddAttribute(HtmlTextWriterAttribute, string) method to render a standard markup attribute.
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 that are 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.
The coding pattern for rendering markup elements is as follows:
Use the erload:System.Web.UI.HtmlTextWriter.AddAttribute method to add any attributes to the element.
Use the erload:System.Web.UI.HtmlTextWriter.RenderBeginTag method.
Use other methods as needed to render the content found between the element's opening and closing tags.
Use the HtmlTextWriter.RenderEndTag method.