System.Web.UI.XhtmlTextWriter Class

Writes Extensible Hypertext Markup Language (XHTML)-specific characters, including all variations of XHTML modules that derive from XTHML, to the output stream for an ASP.NET server control for mobile devices. Override the System.Web.UI.XhtmlTextWriter class to provide custom XHTML rendering for ASP.NET pages and server controls.

See Also: XhtmlTextWriter Members


public class XhtmlTextWriter : HtmlTextWriter


XHTML is an XML-compliant markup language, based on HTML 4.1, which allows you to create Web sites that are suitable for multiple device types. It merges the ease of use provided by HTML with the strict element guidelines provided by XML to produce a markup language with a wide range of format and style options, and with reduced markup tag ambiguity. The System.Web.UI.XhtmlTextWriter class provides formatting capabilities that ASP.NET server controls use when rendering XHTML content to clients. You can use the XhtmlTextWriter.SetDocType(XhtmlMobileDocType) method to specify which type of XHTML the text writer renders. Supported document types are defined in the System.Web.UI.XhtmlMobileDocType enumeration.

The System.Web.UI.XhtmlTextWriter class renders two sets of attributes for elements. One set is a collection of common attributes, as referenced in the XhtmlTextWriter.CommonAttributes property. The second set is a collection of element-specific attributes, as referenced in the XhtmlTextWriter.ElementSpecificAttributes property. For more information on the elements and styles that are rendered, see the XHTML modularization specification at the tp://

You can use the members of the System.Web.UI.XhtmlTextWriter class and any derived classes to create custom text writers to use in custom XHTML page adapters or class adapters. You can also create derived classes that override the standard behavior of the System.Web.UI.XhtmlTextWriter class.

By default, when you are working with browsers that support HTML 4.0, ASP.NET pages and controls render markup that is compatible with the XHTML 1.1 standard. For more information, see ASP.NET and XHTML Compliance.

The System.Web.UI.HtmlTextWriter outputs XHTML unless you configure ASP.NET specifically to not render XHTML markup. For more information, see How to: Configure ASP.NET Web Sites for Non-XHTML Rendering.


Namespace: System.Web.UI
Assembly: System.Web (in System.Web.dll)
Assembly Versions:
Since: .NET 2.0