NextPreviousPagerField.ButtonCssClass Property

 

Gets or sets the cascading style sheet (CSS) class that is used to render the buttons of the pager field on the browser.

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

public string ButtonCssClass { get; set; }

Property Value

Type: System.String

The CSS class used to render the buttons of the pager field on the client. The default is an empty string, which indicates that the ButtonCssClass property is not set.

Use the ButtonCssClass property to specify the CSS class to render on the browser for the buttons of the pager field. This property will always be rendered as the class attribute, regardless of the browser.

System_CAPS_noteNote

On browsers that do not support CSS, setting the ButtonCssClass property has no effect.

The value of this property is stored in viewstate.

The following example shows how to use the ButtonCssClass property to specify a CSS class for buttons in the NextPreviousPagerField object of a DataPager control.

<%@ 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>NextPreviousPagerField Example</title>
    <style type="text/css">
      .pager { background-color:Aqua; }
    </style>
  </head>
  <body>
    <form id="form1" runat="server">

      <h3>NextPreviousPagerField Example</h3>

      <asp:ListView ID="ContactsListView" 
        DataSourceID="ContactsDataSource"
        runat="server">
        <LayoutTemplate>
          <table cellpadding="2" width="640px" border="1" runat="server" id="tblContacts">
            <tr id="itemPlaceholder" runat="server">
            </tr>
          </table>
          <asp:DataPager runat="server" ID="ContactsDataPager">
            <Fields>
              <asp:NextPreviousPagerField 
                  ShowFirstPageButton="true" 
                  ShowLastPageButton="true"
                  FirstPageText="|&lt;&lt; " 
                  LastPageText=" &gt;&gt;|"
                  NextPageText=" &gt; " 
                  PreviousPageText=" &lt; " 
                  ButtonType="Button" 
                  ButtonCssClass="pager" />
            </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>

.NET Framework
Available since 3.5
Return to top
Show: