XHTML Adapter Set
The XHTML adapter set renders ASP.NET mobile Web pages on clients that are capable of rendering XHTML Basic and XHTML, such as Microsoft Internet Explorer for the Pocket PC.
The following table lists the core classes that are included in the XHTML adapter set:
Adapter set | Core adapter class namespace |
---|---|
ControlAdapter base class |
|
FormAdapter class |
|
PageAdapter class |
|
MobileTextWriter class |
Selection
The XHTML adapter set is selected if the preferred rendering type is "xhtml-basic," "xhtml-mp," or "wml20."
Note |
---|
In ASP.NET 2.0, the possible preferred rendering types for XHTML are not part of the MobileCapabilities class. |
Default Rendering
The following describes the default rendering of the page and form adapter classes in the XHTML adapter set.
The page adapter performs the following steps:
Calls the BeginResponse and BeginFile methods on the writer. The content type is
text/html
.Writes out an XML declaration (
<? xml version=1.0 encoding="encodingType" ?>
).Writes out the XHTML document DTD reference.
Writes out an opening
<html xmlns="http://www.w3.org/1999/xhtml" >
tag.Renders the active form.
Writes out a closing
</html>
tag.Calls the EndFile and EndResponse methods.
The form adapter performs the following steps:
Writes out an opening
<title>
element, if one is required.Writes out
<body>
and<form>
tags.Writes out hidden and internal form variables, and writes out postback script.
Renders form contents.
Writes out closing
</form>
and</body>
tags.
Using Styles
The XhtmlMobileTextWriter class provides the following helper methods that aid in using style information to control aspects of character or layout appearance:
The EnterFormat and ExitFormat methods delimit a block of character formatting.
The EnterLayout and ExitLayout methods delimit a block of alignment and wrapping layout.
The EnterStyle and ExitStyle methods delimit a block of both character formatting and alignment and wrapping layout.
A number of properties determine which style properties are written. These properties (such as RenderBold, RenderItalic, and so on) are set when the writer is created, using the device capabilities of the requesting device.
The breakAfter parameter of the ExitLayout, ExitFormat, and ExitStyle methods controls whether a break is inserted after the format and layout tags. If this parameter is set to true, a logical break is rendered in the output using either a <br>
or <div>
tag.
Rendering Postback Controls
By default, form postback controls are rendered as buttons. To use a link as a postback control, you can call the RenderPostBackEventAsAnchor method of the XhtmlControlAdapter base class. This method renders an <a>
tag that posts the form back when the user clicks the link.
You can also create a postback control by setting an attribute of other tags for a control adapter. To do so, you can call the RenderPostBackEventAsAttribute method. You can use this method as part of other tags; for example, you can use the method to create an onClick attribute for a button.
Rendering Links
Links to other pages are rendered as hyperlinks. Links to other forms on the same page are rendered as postback controls.
To render a link for a mobile control adapter, you can call the RenderBeginLink and RenderEndLink methods of the XhtmlControlAdapter base class. The RenderBeginLink method automatically checks for the type of link and renders the appropriate markup.
Secondary UI
The XHTML adapter set supports secondary UI, which is used by controls to show additional screens of the user interface. To use secondary UI, a control adapter performs the following steps:
In response to some user interaction (usually in the overridable HandlePostBackEvent method), the control adapter specifies secondary UI mode by setting the SecondaryUIMode property of the XhtmlControlAdapter base class to an internally known constant.
In rendering, the control checks whether it is in secondary UI mode, and if so, renders the appropriate secondary UI.
In response to user interaction from the secondary UI, the control adapter might change the secondary UI mode to another value, or exit secondary UI mode by calling the ExitSecondaryUIMode method of the XhtmlControlAdapter base class.