HtmlTextWriter.RegisterAttribute Method
Registers HTML attributes, whether literals or dynamically generated, from the source file so that they can be properly rendered to the requesting client.
[Visual Basic] Protected Shared Sub RegisterAttribute( _ ByVal name As String, _ ByVal key As HtmlTextWriterAttribute _ ) [C#] protected static void RegisterAttribute( string name, HtmlTextWriterAttribute key ); [C++] protected: static void RegisterAttribute( String* name, HtmlTextWriterAttribute key ); [JScript] protected static function RegisterAttribute( name : String, key : HtmlTextWriterAttribute );
Parameters
- name
- The HTML attribute to be registered.
- key
- An HtmlTextWriterAttribute value that corresponds with the attribute name.
Example
[Visual Basic] The following code example calls the RegisterAttribute method to associate a custom attribute with a standard HTML attribute. When this HtmlTextWriter is used, using an sz attribute in an HTML element will cause an HTML SIZE attribute to be rendered.
[Visual Basic]
' When this version of the class's constructor is called,
' not only do you specify a tabString, but the code allows
' you to use shortcut elements for the font element,
' size attribute and width style attribute.
Public Sub New(writer As TextWriter, tabString As String)
MyBase.New(writer, tabString)
RegisterTag("f", HtmlTextWriterTag.Font)
RegisterAttribute("sz", HtmlTextWriterAttribute.Size)
RegisterStyle("w", HtmlTextWriterAttribute.Width)
End Sub 'New
[C#, C++, JScript] No example is available for C#, C++, or JScript. To view a Visual Basic 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 | HtmlTextWriterAttribute