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, with optional encoding.
Use the HtmlTextWriter.AddAttribute(string, string, bool) overload of the HtmlTextWriter.AddAttribute(string, string, bool) method if the attribute is not one of the System.Web.UI.HtmlTextWriterAttribute values, or if the attribute is not known until run time and encoding is needed.
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.
Use the HtmlTextWriter.AddAttribute(string, string, bool) method with fEncode set to true, if the attribute can possibly contain a quotation mark ("), a less than sign (<), or an ampersand (&). The method call will encode the attribute to meet the requirements of the requesting device. You can set fEncode to false, if you know that none of these characters will be generated, or if you know that the attribute is already encoded.
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.