Form.ControlToPaginate Property
Gets or sets the control on the form that can be paginated. The default is null (Nothing in Visual Basic). This API is obsolete. For information about how to develop ASP.NET mobile applications, see the www.asp.net/mobile Web site.
Assembly: System.Web.Mobile (in System.Web.Mobile.dll)
<BindableAttribute(False)> <BrowsableAttribute(False)> Public Property ControlToPaginate As Control
The ControlToPaginate property is used to allow a single control on a form to paginate its contents across several views on mobile devices and providing next and previous navigation between views. A control can paginate its contents even if a containing Panel control has its Paginate property set to false.
The following code example demonstrates how to use the ControlToPaginate property of the Form class to specify which control to paginate.
The example creates a page with two forms. One form has a very long string that on some devices must be paginated to give the user access to the entire text. In order to see the pagination in action, you must view the example on a device that handles pagination. In Visual Studio 2005, you can use one of the device emulators available with the Device Emulator Manager on the Tools menu.
Note |
|---|
The following code example uses the single-file code model and may not work correctly if copied directly into a code-behind file. This code example must be copied into an empty text file that has an .aspx extension. For more information, see ASP.NET Web Forms Page Syntax Overview. |
<%@ Page Language="VB" Inherits="System.Web.UI.MobileControls.MobilePage" %> <%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %> <%@ Import Namespace="System.Web.UI.MobileControls" %> <%@ Import Namespace="System.Drawing" %> <script runat="server"> Private Sub Form_Activate(ByVal sender As Object, _ ByVal e As EventArgs) Form1.Wrapping = Wrapping.NoWrap Dim a As String = "This is a very long string <br />" Dim b As String = "START " Dim i As Integer ' Create a long string to force pagination For i = 0 To 100 b &= a Next txtView.Text = b & " END" Form1.ControlToPaginate = txtView End Sub Private Sub Form_Paginated(ByVal sender As Object, _ ByVal e As EventArgs) ' Set the background color based on ' the number of pages If ActiveForm.PageCount > 1 Then ActiveForm.BackColor = Color.LightBlue Else ActiveForm.BackColor = Color.LightGray End If ' Check to see if the Footer template has been chosen If DevSpec.HasTemplates Then Dim lbl As System.Web.UI.MobileControls.Label ' Get the Footer panel Dim pan As System.Web.UI.MobileControls.Panel = Form1.Footer ' Get the Label from the panel lbl = CType(pan.FindControl("lblCount"), System.Web.UI.MobileControls.Label) ' Set the text in the Label lbl.Text = "Page #" + Form1.CurrentPage.ToString() End If End Sub Private Sub Page_Load(ByVal sender As Object, _ ByVal e As EventArgs) ' Set the pager text properties If Not IsPostBack Then Form1.PagerStyle.NextPageText = "Go Next >" Else ' For postback, set different text Form1.PagerStyle.NextPageText = "Go More >" Form1.PagerStyle.PreviousPageText = "< Go Prev" End If End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <body> <!-- The first Form --> <mobile:Form ID="Form1" Runat="server" Paginate="true" OnActivate="Form_Activate" OnPaginated="Form_Paginated"> <mobile:link ID="Link1" Runat="server" NavigateUrl="#Form2"> Go To Other Form </mobile:link> <mobile:Label ID="Label1" Runat="server"> Welcome to ASP.NET </mobile:Label> <mobile:textview ID="txtView" Runat="server" /> <mobile:DeviceSpecific ID="DevSpec" Runat="server"> <Choice> <FooterTemplate> <mobile:Label runat="server" id="lblCount" /> </FooterTemplate> </Choice> </mobile:DeviceSpecific> </mobile:Form> <!-- The second Form --> <mobile:Form ID="Form2" Runat="server" Paginate="true" OnPaginated="Form_Paginated"> <mobile:Label ID="message2" Runat="server"> Welcome to ASP.NET </mobile:Label> <mobile:link ID="Link2" Runat="server" NavigateUrl="#Form1">Back</mobile:link> </mobile:Form> </body> </html>
Available since 1.1
Paginate
Form Class
System.Web.UI.MobileControls Namespace
Introduction to the Form Control
