Partilhar via


Pagination

ASP.NET mobile controls provide pagination, which automatically separates the content in your form into smaller groups of rendered content. When you use pagination, these groups of content are automatically formatted to fit the target device. The form also renders user interface (UI) elements that you can use to browse to other pages.

By default, pagination is not activated for a form. To activate pagination, set the Paginate property of the Form control to true. If Paginate is false, setting the Paginate property on a control within the form has no effect. The Form control also provides other properties, such as PageCount, CurrentPage, and PagerStyle, which allow you to control pagination behavior.

You can also specify pagination for a specific control on a form using the form's ControlToPaginate property.

Recommendations for Using Pagination

Pagination for small interactive forms in an ASP.NET mobile Web page, such as input forms, is often redundant. However, for forms that display large amounts of text or data, pagination can be effective in displaying the information on multiple screens.

When the page contains large quantities of data that changes over time, such as in the case of e-commerce sites where data is being updated constantly, you might consider using custom pagination. For more information about using custom pagination, see the "Custom Pagination" section later in this topic.

Some devices experience memory errors when they try to display more information than their memory can handle. Not only can pagination be effective in displaying forms with large amounts of text or data, but pagination also prevents users from encountering this category of memory errors on their devices.

Device Limitations

Some HTML devices do not support JavaScript (the JavaScript property is false). If you have a form with an Action property set to a nonempty string, the form does not paginate on HTML devices that do not support JavaScript.

Internal Pagination

Mobile controls that are capable of automatic pagination without child controls use internal pagination. For example, a List control can paginate its own items, allowing a form to break the single list into multiple pages. Controls that do not support internal pagination must either have child controls or appear atomically on a single screen.

Controls that support internal pagination use the PagedControl base class to derive pagination properties, methods, and events for internal and custom pagination. Properties such as the FirstVisibleItemIndex property provide access to the individual items on a page. Other properties provide the weight of an item and the count of visible items.

The List, ObjectList, and TextView controls support internal pagination.

Custom Pagination

Controls that support internal pagination also support custom pagination. Normally, controls require the data for all pages to be provided at once, and then discard all but the current page. For custom pagination, controls raise an event to load only the items for the current page. You can specify the total number of items in the ItemCount property. If you change the ItemCount property from its default value of zero, the control will use custom pagination. In that case, the control raises the LoadItems event, which can call an application-specified event handler to provide the items for the current page. The event handler retrieves the appropriate data and binds the data to the control.

See Also

Concepts

Forms

Pages

Panels

Styles

Other Resources

Design and Rendering Concepts for ASP.NET Mobile Controls

Application Developer's Guide