Share via


HTML Adapter Set

The HTML adapter set renders ASP.NET mobile Web Forms pages on clients capable of rendering HTML 3.2 with scripting enabled, such as Microsoft Internet Explorer for the Pocket PC.

The following table lists the core classes included in the HTML adapter set.

Adapter set Core adapter class namespace
ControlAdapter base class System.Web.UI.MobileControls.Adapters.HtmlControlAdapter
FormAdapter class System.Web.UI.MobileControls.Adapters.HtmlFormAdapter
PageAdapter class System.Web.UI.MobileControls.Adapters.HtmlControlAdapter
TextWriter class System.Web.UI.MobileControls.Adapters.HtmlMobileTextWriter

Selection

The HTML adapter set is selected if the PreferredRenderingType property of the MobileCapabilities class returns html32, and the JavaScriptproperty of the browser capabilities class returns true.

Default Rendering

The following are the default renderings of the page and form adapter classes in the HTML adapter set.

The page adapter performs the following steps:

  1. Call BeginResponse and BeginFile on the writer. Content type is text/html.
  2. Write out an opening <html> tag.
  3. Render the active form.
  4. Write out a closing </html> tag.
  5. Call the EndFile and EndResponse methods.

The form adapter performs the following steps:

  1. Write out an opening <title> tag, if one is required.
  2. Write out <body> and <form> tags.
  3. Write out hidden and internal form variables, and postback script.
  4. Render form contents.
  5. Write out closing </form> and </body> tags.

Using Styles

The HtmlMobileTextWriter class provides a number of helper methods that aid in using style information to control some aspect of the character or layout appearance:

A number of properties control 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 appears in the output through use of either a <br> or <div> tag.

Rendering Postbacks

Form postbacks are rendered as calls to a piece of script that is written out with the form.

To render a postback event as an anchor for an adapter, you can call the RenderPostBackEventAsAnchor method of the HtmlControlAdapter base class. This method writes out an <a> tag and generates a postback when the user clicks the link.

To render a postback event as an attribute of another tag for a control adapter, you can call the RenderPostBackEventAsAttribute method. You can use this method as part of other tags; for example, you can write out 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 form postbacks.

To render a link for a mobile control adapter, you can call the RenderBeginLink and RenderEndLink methods of the HtmlControlAdapter base class. The RenderBeginLink method automatically checks for the type of link and renders the appropriate markup.

Secondary UI

The HTML adapter set supports a concept called secondary UI. Secondary UI is used by controls that show additional screens of a user interface. To use secondary UI, a control adapter performs the following steps:

  1. In response to some user interaction (usually in the HandlePostBackEvent method, which is overridable), the control adapter sets the secondary UI mode to an internally known constant, by setting the SecondaryUIMode property of the HtmlControlAdapter base class.
  2. In rendering, the control checks whether it is in secondary UI mode, and uses the mode to render 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 HtmlControlAdapter base class.