Adds the specified markup style attribute and the attribute value to the opening markup tag created by a subsequent call to the erload:System.Web.UI.HtmlTextWriter.RenderBeginTag method.
Use the HtmlTextWriter.AddStyleAttribute(string, string) overload of the HtmlTextWriter.AddStyleAttribute(string, string) method when the style is not a member of the System.Web.UI.HtmlTextWriterStyle enumeration or is not known until run time.
The System.Web.UI.HtmlTextWriter class maintains a list of styles for the markup elements it renders. When the erload:System.Web.UI.HtmlTextWriter.RenderBeginTag method is called, any styles that are added by the erload:System.Web.UI.HtmlTextWriter.AddStyleAttribute method are rendered to the opening tag of the element. The list of styles is then cleared.
The coding pattern for rendering markup elements is as follows:
Use the erload:System.Web.UI.HtmlTextWriter.AddStyleAttribute method to add any style 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 opening and closing tags.
Use the HtmlTextWriter.RenderEndTag method.