Compartilhar via


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

XhtmlControlAdapter

FormAdapter class

XhtmlFormAdapter

PageAdapter class

XhtmlPageAdapter

MobileTextWriter class

XhtmlMobileTextWriter

Selection

The XHTML adapter set is selected if the preferred rendering type is "xhtml-basic," "xhtml-mp," or "wml20."

NoteNote

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:

  1. Calls the BeginResponse and BeginFile methods on the writer. The content type is text/html.

  2. Writes out an XML declaration (<? xml version=1.0 encoding="encodingType" ?>).

  3. Writes out the XHTML document DTD reference.

  4. Writes out an opening <html xmlns="http://www.w3.org/1999/xhtml" > tag.

  5. Renders the active form.

  6. Writes out a closing </html> tag.

  7. Calls the EndFile and EndResponse methods.

The form adapter performs the following steps:

  1. Writes out an opening <title> element, if one is required.

  2. Writes out <body> and <form> tags.

  3. Writes out hidden and internal form variables, and writes out postback script.

  4. Renders form contents.

  5. 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:

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.

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:

  1. 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.

  2. In rendering, the control checks whether it is in secondary UI mode, and if so, renders the appropriate secondary UI.

  3. 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.

See Also

Concepts

Adapter Sets Functionality