.NET Framework Class Library NumericPagerField Class Represents a DataPager field that enables users to select a page by page number.

Inheritance Hierarchy
Namespace:
System.Web.UI.WebControls
Assembly:
System.Web.Extensions (in System.Web.Extensions.dll)

Syntax
Public Class NumericPagerField _
Inherits DataPagerField
public class NumericPagerField : DataPagerField
public ref class NumericPagerField : public DataPagerField
type NumericPagerField =
class
inherit DataPagerField
end
The NumericPagerField type exposes the following members.

Constructors

Properties

Methods

Explicit Interface Implementations

Remarks
The NumericPagerField class displays navigation controls in a DataPager control. The controls can be used to page through data that is displayed by a control that implements the IPageableItemContainer interface, such as the ListView control. The NumericPagerField object displays page numbers as buttons that users can click to move to specific a page. The control also displays next-page and previous-page buttons that enable users to access more pages of data than the ones that are displayed by the control. You can customize the appearance of the NumericPagerField object by using the properties that are listed in the following table. You can use the ButtonType property to select the type of button that will be displayed. The following table lists the available button types. Button type | Description |
|---|
ButtonType..::.Button | A Button control. | ButtonType..::.Image | An ImageButton control. | ButtonType..::.Link | A LinkButton control. |
The controls inside the NumericButtonCssClass object are rendered with non-breaking spaces between them. If you want to customize this behavior, you can use the RenderNonBreakingSpacesBetweenControls property. You can hide a NumericPagerField object in a DataPager control by setting the Visible property to false. You cannot control the visibility of the next-page and previous-page buttons. They are displayed by the control if the associated data control has additional pages available to display. You can use the ButtonCount property to specify how many buttons are displayed in a NumericPagerField object. Each button corresponds to a page number. You can set the text of the next-page button by setting the NextPageText property. You can set the text of the previous-page button by using the PreviousPageText property. When the ButtonType property is set to ButtonType..::.Image, you must provide the URL of an image that will be displayed for the next-page and previous page buttons. You do this by setting the NextPageImageUrl and PreviousPageImageUrl properties. In that case, the corresponding text property is used as the alternate text for the image. For example, the text that is specified by the NextPageImageUrl property is displayed as the alternate text for the next-page image button. On browsers that support tooltips, this text is also displayed as a tooltip for the corresponding button.

Examples
The following example shows how to use a NumericPagerField object to page through data that is displayed in a ListView control.
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head id="Head1" runat="server">
<title>NumericPagerField Example</title>
<style type="text/css">
body
{
text-align: center;
font: 12px Arial, Helvetica, sans-serif;
}
table
{
padding: 2px 2px 2px 2px;
border: 1px solid;
width: 500px;
}
.CurrentPage
{
padding: 2px 6px;
border: solid 1px #ddd;
background: #2E8B57;
color:White;
}
.PrevNext,.PageNumber
{
padding: 2px 6px;
border: solid 1px #ddd;
text-decoration: none;
color: #2E8B57;
}
.PageNumber:hover, .PrevNext:hover
{
background-color: #FFA500;
color: White;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>NumericPagerField Example</h3>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
runat="server">
<LayoutTemplate>
<table runat="server" id="tblContacts">
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td align="left">
<asp:Label ID="NameLabel" runat="server"
Text='<%#Eval("LastName") & ", " & Eval("FirstName")%>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<br />
<div>
<asp:DataPager runat="server"
ID="ContactsDataPager"
PagedControlID="ContactsListView">
<Fields>
<asp:NumericPagerField
PreviousPageText="< Prev"
NextPageText="Next >"
ButtonCount="10"
NextPreviousButtonCssClass="PrevNext"
CurrentPageLabelCssClass="CurrentPage"
NumericButtonCssClass="PageNumber" />
</Fields>
</asp:DataPager>
</div>
<br />
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName]
FROM Person.Contact">
</asp:SqlDataSource>
</form>
</body>
</html>
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head id="Head1" runat="server">
<title>NumericPagerField Example</title>
<style type="text/css">
body
{
text-align: center;
font: 12px Arial, Helvetica, sans-serif;
}
table
{
padding: 2px 2px 2px 2px;
border: 1px solid;
width: 500px;
}
.CurrentPage
{
padding: 2px 6px;
border: solid 1px #ddd;
background: #2E8B57;
color:White;
}
.PrevNext,.PageNumber
{
padding: 2px 6px;
border: solid 1px #ddd;
text-decoration: none;
color: #2E8B57;
}
.PageNumber:hover, .PrevNext:hover
{
background-color: #FFA500;
color: White;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>NumericPagerField Example</h3>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
runat="server">
<LayoutTemplate>
<table runat="server" id="tblContacts">
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td align="left">
<asp:Label ID="NameLabel" runat="server"
Text='<%#Eval("LastName") + ", " + Eval("FirstName")%>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<br />
<div>
<asp:DataPager runat="server"
ID="ContactsDataPager"
PagedControlID="ContactsListView">
<Fields>
<asp:NumericPagerField
PreviousPageText="< Prev"
NextPageText="Next >"
ButtonCount="10"
NextPreviousButtonCssClass="PrevNext"
CurrentPageLabelCssClass="CurrentPage"
NumericButtonCssClass="PageNumber" />
</Fields>
</asp:DataPager>
</div>
<br />
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName]
FROM Person.Contact">
</asp:SqlDataSource>
</form>
</body>
</html>

Version Information
.NET FrameworkSupported in: 4, 3.5

Platforms
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role not supported), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Thread Safety
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also
|
Bibliothèque de classes .NET Framework NumericPagerField, classe Représente un champ DataPager qui permet aux utilisateurs de sélectionner une page par son numéro de page.

Hiérarchie d'héritage
Espace de noms :
System.Web.UI.WebControls
Assembly :
System.Web.Extensions (dans System.Web.Extensions.dll)

Syntaxe
Public Class NumericPagerField _
Inherits DataPagerField
public class NumericPagerField : DataPagerField
public ref class NumericPagerField : public DataPagerField
type NumericPagerField =
class
inherit DataPagerField
end
Le type NumericPagerField expose les membres suivants.

Constructeurs

Méthodes

Implémentations d'interface explicite

Notes
La classe NumericPagerField affiche des contrôles de navigation dans un contrôle DataPager. Les contrôles peuvent être utilisés pour paginer parmi des données affichées par un contrôle qui implémente l'interface IPageableItemContainer, comme le contrôle ListView. L'objet NumericPagerField affiche les numéros de page sous forme de boutons sur lesquels les utilisateurs peuvent cliquer pour accéder à une page spécifique. Le contrôle affiche également des boutons Page suivante et Page précédente qui permettent aux utilisateurs d'accéder à davantage de pages de données que celles affichées par le contrôle. Vous pouvez personnaliser l'apparence de l'objet NumericPagerField en utilisant les propriétés répertoriées dans le tableau suivant. Vous pouvez utiliser la propriété ButtonType pour sélectionner le type de bouton qui sera affiché. Le tableau suivant répertorie les types de bouton disponibles. Type de bouton | Description |
|---|
ButtonType..::.Button | un contrôle Button. | ButtonType..::.Image | Contrôle ImageButton. | ButtonType..::.Link | un contrôle LinkButton. |
Les contrôles à l'intérieur de l'objet NumericButtonCssClass sont restitués avec des espaces insécables entre eux. Si vous souhaitez personnaliser ce comportement, vous pouvez utiliser la propriété RenderNonBreakingSpacesBetweenControls. Vous pouvez masquer un objet NumericPagerField dans un contrôle DataPager en affectant la valeur false à la propriété Visible. Vous ne pouvez pas contrôler la visibilité des boutons Page suivante et Page précédente. Ils sont affichés par le contrôle si le contrôle de données associé dispose de pages supplémentaires disponibles à afficher. Vous pouvez utiliser la propriété ButtonCount pour spécifier combien de boutons sont affichés dans un objet NumericPagerField. Chaque bouton correspond à un numéro de page. Vous pouvez définir le texte du bouton Page suivante en définissant la propriété NextPageText. Vous pouvez définir le texte du bouton Page précédente à l'aide de la propriété PreviousPageText. Lorsque la valeur de la propriété ButtonType est ButtonType..::.Image, vous devez fournir l'URL d'une image à afficher pour les boutons Page suivante et Page précédente. Pour ce faire, vous devez définir les propriétés NextPageImageUrl et PreviousPageImageUrl. Dans ce cas, la propriété Texte correspondante est utilisée comme texte de remplacement pour l'image. Par exemple, le texte spécifié par la propriété NextPageImageUrl est affiché en tant que texte de remplacement pour le bouton d'image de Page suivante. Dans les navigateurs qui prennent en charge la fonctionnalité Info-bulles, ce texte s'affiche également sous forme d'info-bulle pour le bouton correspondant.

Exemples
L'exemple suivant indique comment utiliser un objet NumericPagerField pour parcourir les données affichées dans un contrôle ListView.
<%@ Page language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head id="Head1" runat="server">
<title>NumericPagerField Example</title>
<style type="text/css">
body
{
text-align: center;
font: 12px Arial, Helvetica, sans-serif;
}
table
{
padding: 2px 2px 2px 2px;
border: 1px solid;
width: 500px;
}
.CurrentPage
{
padding: 2px 6px;
border: solid 1px #ddd;
background: #2E8B57;
color:White;
}
.PrevNext,.PageNumber
{
padding: 2px 6px;
border: solid 1px #ddd;
text-decoration: none;
color: #2E8B57;
}
.PageNumber:hover, .PrevNext:hover
{
background-color: #FFA500;
color: White;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>NumericPagerField Example</h3>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
runat="server">
<LayoutTemplate>
<table runat="server" id="tblContacts">
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td align="left">
<asp:Label ID="NameLabel" runat="server"
Text='<%#Eval("LastName") & ", " & Eval("FirstName")%>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<br />
<div>
<asp:DataPager runat="server"
ID="ContactsDataPager"
PagedControlID="ContactsListView">
<Fields>
<asp:NumericPagerField
PreviousPageText="< Prev"
NextPageText="Next >"
ButtonCount="10"
NextPreviousButtonCssClass="PrevNext"
CurrentPageLabelCssClass="CurrentPage"
NumericButtonCssClass="PageNumber" />
</Fields>
</asp:DataPager>
</div>
<br />
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName]
FROM Person.Contact">
</asp:SqlDataSource>
</form>
</body>
</html>
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head id="Head1" runat="server">
<title>NumericPagerField Example</title>
<style type="text/css">
body
{
text-align: center;
font: 12px Arial, Helvetica, sans-serif;
}
table
{
padding: 2px 2px 2px 2px;
border: 1px solid;
width: 500px;
}
.CurrentPage
{
padding: 2px 6px;
border: solid 1px #ddd;
background: #2E8B57;
color:White;
}
.PrevNext,.PageNumber
{
padding: 2px 6px;
border: solid 1px #ddd;
text-decoration: none;
color: #2E8B57;
}
.PageNumber:hover, .PrevNext:hover
{
background-color: #FFA500;
color: White;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>NumericPagerField Example</h3>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
runat="server">
<LayoutTemplate>
<table runat="server" id="tblContacts">
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:Label ID="IDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td align="left">
<asp:Label ID="NameLabel" runat="server"
Text='<%#Eval("LastName") + ", " + Eval("FirstName")%>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<br />
<div>
<asp:DataPager runat="server"
ID="ContactsDataPager"
PagedControlID="ContactsListView">
<Fields>
<asp:NumericPagerField
PreviousPageText="< Prev"
NextPageText="Next >"
ButtonCount="10"
NextPreviousButtonCssClass="PrevNext"
CurrentPageLabelCssClass="CurrentPage"
NumericButtonCssClass="PageNumber" />
</Fields>
</asp:DataPager>
</div>
<br />
<!-- This example uses Microsoft SQL Server and connects -->
<!-- to the AdventureWorks sample database. Use an ASP.NET -->
<!-- expression to retrieve the connection string value -->
<!-- from the Web.config file. -->
<asp:SqlDataSource ID="ContactsDataSource" runat="server"
ConnectionString="<%$ ConnectionStrings:AdventureWorks_DataConnectionString %>"
SelectCommand="SELECT [ContactID], [FirstName], [LastName]
FROM Person.Contact">
</asp:SqlDataSource>
</form>
</body>
</html>

Informations de version
.NET FrameworkPris en charge dans : 4, 3.5

Plateformes
Windows 7, Windows Vista SP1 ou ultérieur, Windows XP SP3, Windows Server 2008 (installation minimale non prise en charge), Windows Server 2008 R2 (installation minimale prise en charge avec SP1 ou version ultérieure), Windows Server 2003 SP2
Le .NET Framework ne prend pas en charge toutes les versions de chaque plateforme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise du .NET Framework.

Sécurité des threads
Tous les membres static ( Shared en Visual Basic) publics de ce type sont thread-safe. Il n'est pas garanti que les membres d'instance soient thread-safe.

Voir aussi
RéférenceAutres ressources
|