HtmlTextWriter.GetStyleName Method (HtmlTextWriterStyle)

 

Obtains the markup style attribute name associated with the specified HtmlTextWriterStyle enumeration value.

Namespace:   System.Web.UI
Assembly:  System.Web (in System.Web.dll)

member GetStyleName : 
        styleKey:HtmlTextWriterStyle -> string

Parameters

styleKey
Type: System.Web.UI.HtmlTextWriterStyle

The HtmlTextWriterStyle to obtain the style attribute name for.

Return Value

Type: System.String

The style attribute name associated with the HtmlTextWriterStyle enumeration value specified in styleKey.

If styleKey is not a valid HtmlTextWriterStyle object, the GetStyleName method returns an empty string ("").

The following code example shows how to check whether a <label> element is being rendered. If so, it checks whether a Color style attribute has been defined on the element. If the attribute has not been defined, the AddStyleAttribute method is called and the GetStyleName method converts the Color enumeration member into its string representation to pass to the AddStyleAttribute method.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top
Show: