Introduction to the Form Control
Most pages on the World Wide Web are too complex to be displayed on current mobile devices, such as Web phones. The Form control in the ASP.NET mobile controls enables designers to break up complex nonmobile pages into a collection of forms on a mobile Web Forms page. With this ability, page designers can minimize the effort required to port their Web-based applications to mobile devices. For further information, see Organizing Content with Containers.
ASP.NET mobile Web Forms pages can contain more than one Form control. However, when they are displayed on a mobile device, mobile Web applications display only one mobile Web Form control at a time. Mobile Web applications can programmatically set the current form. They can also provide the user with links between forms on the same page.
Form controls contain content and other controls. In effect, a mobile Web Form control can be thought of as a "page within a page." All Form controls on a page share the same code-behind file and page state information. Using multiple forms on a mobile Web Forms page helps reduce the number of physical page files in your application, and thus improves performance during run time.
A mobile Web Forms page must contain at least one Form control. All other controls, with the exception of the StyleSheet control and the DeviceSpecific control, must be placed within a Form control, a Panel control, or a control's template.
When a user browses to a mobile Web Forms page, the first form on that page appears by default. For information about how to change this default programmatically, see the Form Activation section of the Form Class topic.
Set the background and text color with the BackColor and ForeColor properties in the Properties window of the ASP.NET mobile designer. You can also type literal text directly in a Form control, which will flow around other controls that you add. Format the text by using the Bold and Italic properties, which are in the Font property.
The displays of mobile devices differ widely in their capabilities. The Form control offers powerful features for customizing the presentation of content and controls for particular types of mobile devices. Using a DeviceSpecific control, developers can apply device filters to forms. These enable the use of property override values and control templates.
Applications can provide event handlers to achieve further customization of the Form control. A form raises an Activate event when it becomes the current form. The Deactivate event occurs when it is no longer the active form.
If a form's content is long, it can be paginated on some mobile devices. Each screen in the paginated form has a current page number. Page numbers begin with 1. The Form control keeps the current page number in its CurrentPage property. Whenever the Form control paginates its content, it also displays user interface elements that enable the user to navigate between the pages. Set the style of the pagination user interface elements by using the Form control's PagerStyle property.