MobilePage Control
This is the base class for all mobile ASP.NET pages. As such, the MobilePage control provides the outermost layer of all the containers in an ASP.NET mobile Web application. It is the only container associated with a URL and primarily contains style and context information common to all controls.
As shown in the syntax, a mobile page requires two directives. The first directive instructs the ASP.NET page framework to use MobilePage as the base class for the page. The Inherits attribute is required. If the page inherits directly from a MobilePage object, the Inherits attribute must be set to the System.Web.UI.MobileControls.MobilePage namespace. If the page inherits from a code-behind class, the name of the class must be specified instead. The Language attribute is optional; you can set it to the language used on the page, as with any other Web Forms page.
The second directive registers the namespace used by ASP.NET mobile controls that have the mobile prefix. This allows you to declare mobile controls on the page by using the mobile prefix.
<mobile:List...></mobile:list>
Although you can use any prefix you want, the mobile prefix is strongly recommended for forward compatibility.
Mobile Controls Syntax
Required properties, defaults, and code-featured elements are noted in bold type.
<%@ Page Inherits="System.Web.UI.MobileControls.MobilePage" Language="c#" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
Containment Rules
The MobilePage control is the base control for an ASP.NET mobile Web application and is not contained by any other controls. A MobilePage object can contain the following controls.
Control | Comments |
---|---|
System.Web.UI.MobileControls.Form | A MobilePage object must contain at least one Form control and can contain more than more than one Form control. |
System.Web.UI.MobileControls.Stylesheet | A style sheet is not required for a MobilePage object.
0 or 1 StyleSheet controls can be contained in a MobilePage control. |
Device Templates
None.
Device-Specific Behavior
Rendering of content within a page differs across devices.
Example
This example creates a mobile page and a form, and then adds a label to the form.
<%@ Page Inherits= "System.Web.UI.MobileControls.MobilePage" %>
<%@ Register TagPrefix="mobile"
Namespace="System.Web.UI.MobileControls"
Assembly="System.Web.Mobile" %>
<mobile:Form runat="server">
<mobile:Label runat="server">
My First MobilePage, Form, and Label
</mobile:Label>
</mobile:Form>
See Also
MobilePage Class | MobilePage Class Members | Control Reference