Jaa


Pagination Support

Wireless devices use screens of widely differing capabilities. Some screens provide support for a very rich display of content. Others display a few lines of monochrome text. Content for basic screens must often be paginated to be displayed properly. ASP.NET mobile controls enable your application to automatically paginate forms into pages that are appropriate for the target device. This section describes how mobile controls can participate in the pagination process.

Understanding the Pagination Weighting System

The form pagination process is based on a weighting system. Every page adapter returns an optimum page weight for a form, through the OptimumPageWeight property.

A device adapter set can provide optimum weights for a page and for each control. The choice of units for these weights is flexible. Although you can coordinate an appropriate convention for weight units, if you follow the default unit system, you can use the default weights of the controls for a set of device adapters.

Note

The default unit system is based on one line equaling 100 units, as indicated by the DefaultWeight constant in the ControlPager class.

When paginating, the ASP.NET iterates through the control tree, calculating weights and assigning page numbers. After ASP.NET renders the current page, it performs the appropriate pagination. You can determine a control's assigned page or pages by using the FirstPage and LastPage properties.

The pagination algorithm takes into account the control setting that prevents pagination across multiple pages. For example, you might not want to allow a Panel control's contents to be broken up across several pages. To prevent a control's contents from being paginated, override the PaginateChildren property in the control implementation and return false.

Supporting Basic Pagination

To ensure proper pagination, a control must override the VisibleWeight property and then return a weight. The default weight is 100, which corresponds to one line in the default unit system.

Alternatively, if you want the control weight to be device-specific, the control adapter can override the VisibleWeight property with the value that is appropriate for a particular device. The MobileControl base class implementation of the VisibleWeight property retrieves this value from the device adapter.

Designing for Internal and Custom Pagination

Some controls use pagination to break up the content in the controls across multiple form pages, even when they do not contain child controls. For example, a List control with a large number of items might paginate itself across multiple form pages. This is called internal pagination. Controls that are capable of internal pagination are also capable of custom pagination. Custom pagination provides a callback function to the application that allows it to provide the necessary data to the control on demand, and that groups related data.

Preventing Pagination

Pagination breaks the content of controls across multiple pages. In some cases, you might want to prevent a control from paginating across multiple pages. For example, you might want to prevent a Panel control from being paginated. The Panel control has a Paginate property, which is set to false by default.

See Also

Other Resources

Adding New Device Adapters and Device Support