This documentation is archived and is not being maintained.

HtmlTextWriter.RegisterStyle Method

Registers HTML style properties, 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 RegisterStyle( _
   ByVal name As String, _
   ByVal key As HtmlTextWriterStyle _
)
[C#]
protected static void RegisterStyle(
 string name,
 HtmlTextWriterStyle key
);
[C++]
protected: static void RegisterStyle(
 String* name,
 HtmlTextWriterStyle key
);
[JScript]
protected static function RegisterStyle(
   name : String,
 key : HtmlTextWriterStyle
);

Parameters

name
The String passed from the source file specifying the style name.
key
The HtmlTextWriterStyle value that corresponds with the specified style.

Example

[Visual Basic] The following code example calls the RegisterStyle method to associate a custom style attribute with a standard HTML attribute. When this HtmlTextWriter is used, creating an w style attribute will cause an HTML Width style 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 Language Filter 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

Show: