NumericPagerField.CurrentPageLabelCssClass 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置用于设置当前页码样式的级联样式表 (CSS) 类。
public:
property System::String ^ CurrentPageLabelCssClass { System::String ^ get(); void set(System::String ^ value); };
public string CurrentPageLabelCssClass { get; set; }
member this.CurrentPageLabelCssClass : string with get, set
Public Property CurrentPageLabelCssClass As String
属性值
用于设置浏览器中当前页码的样式的 CSS 类。 默认值为空字符串 (""),表示尚未设置 CurrentPageLabelCssClass 属性。
示例
下面的示例演示如何指定 CSS 类来设置控件 的 对象中的 NumericPagerField 当前页码的 DataPager 样式。
<%@ Page language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>NumericPagerField Example</title>
<style type="text/css">
.PagerNormal
{
font: 9pt Verdana;
color: #0066CF;
border: solid 1px #778899;
padding: 1px 4px;
text-decoration:none;
}
.PagerCurrent
{
font: 9pt Verdana;
border: solid 1px #778899;
padding: 1px 4px;
background-color: #FFD700;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>NumericPagerField Example</h3>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
runat="server">
<LayoutTemplate>
<table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
<tr runat="server">
<th runat="server">ID</th>
<th runat="server">First Name</th>
<th runat="server">Last Name</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
<br />
<asp:DataPager runat="server" ID="ContactsDataPager" PagedControlID="ContactsListView">
<Fields>
<asp:NumericPagerField
ButtonCount="10"
CurrentPageLabelCssClass="PagerCurrent"
NextPreviousButtonCssClass="PagerNormal"
NumericButtonCssClass="PagerNormal"
NextPageText=">>"
PreviousPageText="<<" />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:Label ID="ContactIDLabel" runat="server" Text='<%#Eval("ContactID") %>' />
</td>
<td>
<asp:Label ID="FirstNameLabel" runat="server" Text='<%#Eval("FirstName") %>' />
</td>
<td>
<asp:Label ID="LastNameLabel" runat="server" Text='<%#Eval("LastName") %>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<!-- 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="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>NumericPagerField Example</title>
<style type="text/css">
.PagerNormal
{
font: 9pt Verdana;
color: #0066CF;
border: solid 1px #778899;
padding: 1px 4px;
text-decoration:none;
}
.PagerCurrent
{
font: 9pt Verdana;
border: solid 1px #778899;
padding: 1px 4px;
background-color: #FFD700;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<h3>NumericPagerField Example</h3>
<asp:ListView ID="ContactsListView"
DataSourceID="ContactsDataSource"
runat="server">
<LayoutTemplate>
<table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
<tr runat="server">
<th runat="server">ID</th>
<th runat="server">First Name</th>
<th runat="server">Last Name</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
<br />
<asp:DataPager runat="server" ID="ContactsDataPager" PagedControlID="ContactsListView">
<Fields>
<asp:NumericPagerField
ButtonCount="10"
CurrentPageLabelCssClass="PagerCurrent"
NextPreviousButtonCssClass="PagerNormal"
NumericButtonCssClass="PagerNormal"
NextPageText=">>"
PreviousPageText="<<" />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<tr runat="server">
<td>
<asp:Label ID="ContactIDLabel" runat="server" Text='<%# Eval("ContactID") %>' />
</td>
<td>
<asp:Label ID="FirstNameLabel" runat="server" Text='<%# Eval("FirstName") %>' />
</td>
<td>
<asp:Label ID="LastNameLabel" runat="server" Text='<%# Eval("LastName") %>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
<!-- 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>
注解
CurrentPageLabelCssClass使用 属性可以指定 CSS 类,该类用于设置对象样式Label,该对象表示当前选定的页码。 无论浏览器如何,属性 CurrentPageLabelCssClass 始终呈现为 class
属性。
注意
在不支持 CSS 的浏览器上 CurrentPageLabelCssClass ,设置 属性不起作用。
此属性的值存储在视图状态中。