HtmlTextWriter.GetStyleKey Method (String)
Obtains the HtmlTextWriterStyle enumeration value for the specified style.
Assembly: System.Web (in System.Web.dll)
Parameters
- styleName
-
Type:
System.String
The style attribute for which to obtain the HtmlTextWriterStyle.
Return Value
Type: System.Web.UI.HtmlTextWriterStyleThe HtmlTextWriterStyle enumeration value corresponding to styleName.
The GetStyleKey method returns the value -1 typed as a HtmlTextWriterStyle value, if styleName does not correspond to any HtmlTextWriterStyle enumeration value.
The following code example demonstrates how to override the RenderBeginTag method in a class derived from the HtmlTextWriter class. The RenderBeginTag override determines whether a <label> markup will be rendered, and, if so, checks the element for a Color attribute. If a Color attribute has not been defined, the GetStyleKey method is used as the first parameter in a call to the AddStyleAttribute method to add a Color attribute to a <label> markup element and set the Color attribute to red.
Available since 1.1