Freigeben über


Pages 

ASP.NET mobile Web pages are objects that inherit from the MobilePage class, either directly or indirectly. The inheritance chain of a mobile Web page depends on how the page is written. If a mobile Web page is self-contained, it inherits directly from the MobilePage class. A mobile Web page can also inherit from a custom class that in turn inherits from the MobilePage class.

Forms on Mobile Web Pages

Unlike ordinary ASP.NET Web pages, mobile Web pages rely on multiple forms to organize the page's content. A mobile page typically presents information to the user with a succession of forms, and if the data in one form is larger than the device can display, the form can paginate the information onto several screens.

When building a Web application, in general you use forms within a single mobile Web page instead of creating new, separate mobile Web pages. Create a new mobile Web page only when you want to:

  • Present a different URL to the user.

  • Increase performance.

@ Page Directive for Mobile Web Pages

For backward compatibility, every ASP.NET mobile Web page must contain the following @ Page directive.

<%@ Page Inherits = 
        "System.Web.UI.MobileControls.MobilePage" Language="C#" %>
<%@ Page Inherits = 
        "System.Web.UI.MobileControls.MobilePage" Language="VB" %>
NoteNote

When you create a mobile Web page in Visual Studio, the @ Page directive is added for you automatically.

The directive instructs the Web page compiler to use the MobilePage class as the base class for the page. The Inherits attribute of the @ Pagedirective is required. If the page inherits directly from the MobilePage class, the Inherits attribute must be set to the System.Web.UI.MobileControls.MobilePage class. If the page inherits from another class, you specify the name of that class instead. The Language attribute is optional, and can be set to the language used on the page.

NoteNote

If you are writing an application that targets the .NET Framework version 1.0, the page must include an @ Register directive with a TagPrefix attribute. The @ Register directive maps the namespace for ASP.NET mobile controls to the mobile prefix. This enables you to declare mobile controls on the page using the mobile prefix in a tag, such as in the tag <mobile:Label>. Although you can use any prefix, the mobile prefix is strongly recommended for forward compatibility and consistency within ASP.NET. The following example shows an @ Register directive for a mobile page:

<%@ Register TagPrefix="mobile" 
         Namespace="System.Web.UI.MobileControls" 
         Assembly="System.Web.Mobile" %>

See Also

Reference

MobilePage

Concepts

Forms
Panels
Pagination
Styles

Other Resources

Application Developer's Guide
Design and Rendering Concepts for ASP.NET Mobile Controls