HtmlTextWriter.GetAttributeName Method
Obtains the name of the HTML attribute associated with the specified HtmlTextWriterAttribute value.
[Visual Basic] Protected Function GetAttributeName( _ ByVal attrKey As HtmlTextWriterAttribute _ ) As String [C#] protected string GetAttributeName( HtmlTextWriterAttribute attrKey ); [C++] protected: String* GetAttributeName( HtmlTextWriterAttribute attrKey ); [JScript] protected function GetAttributeName( attrKey : HtmlTextWriterAttribute ) : String;
Parameters
- attrKey
- The HtmlTextWriterAttribute to obtain the HTML attribute name for.
Return Value
The name of the HTML attribute.
Example
[Visual Basic, C#, C++] The following example shows a custom HtmlTextWriter class that overrides the RenderBeginTag method. It determines whether the HTML element to be rendered is a < font > element, and, if so, checks the element for a size attribute. If a size attribute has not been defined, the GetAttributeName method is used as the first parameter in an AddAttribute method call to add a size attribute to an HTML < font > element. The second parameter sets the size attribute to 30 points.
[Visual Basic] ' Use the GetAttributeName method to ensure that the ' Size attribute is written properly. writer.Write(GetAttributeName(HtmlTextWriterAttribute.Size)) [C#] // Use the GetAttributeName method to ensure that the // Size attribute is written properly. writer.Write(GetAttributeName(HtmlTextWriterAttribute.Size)); [C++] // Use the GetAttributeName method to ensure that the // Size attribute is written properly. writer->Write(GetAttributeName(HtmlTextWriterAttribute::Size));
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
See Also
HtmlTextWriter Class | HtmlTextWriter Members | System.Web.UI Namespace