Tutorials to .com

Tutorials to .com » Dotnet » Control-and-components » A paging control

A paging control

Print View , by: iSee ,Total views: 10 ,Word Count: 712 ,Date: Thu, 21 May 2009 Time: 5:02 PM

pager.ascx

<% @ Control Language = "c #" AutoEventWireup = "false" Codebehind = "pager.ascx.cs" Inherits = "Web.pagercontrol" TargetSchema = "http://schemas.microsoft.com/intellisense/ie5"%>
var currentpage = <% = pageindex %>;// the first few pages of the current
var p = <% = pageindex%> -1;
var sum = <% = sum%>;
var perpage = <% = perpage%>;
var urlstr ='<%= urlstr%> ';
var fontcolor ='<%= fontcolor%> ';
/ / n the total number of pages on behalf of a
if (sum% perpage == 0)
(
n = sum / perpage;
)
else
(
n = (sum-sum% perpage) / perpage +1;
)
document.write ( '<table border = "0" cellpadding = "0" cellspacing = "3" width ="<%= tablewidth%> "align =" center ">');
document.write ( '<form method=post action="'+urlstr+'">');
document.write ( '<tr style="font-size: 12px;"> <td valign="middle">');
document.write ( 'Page: <b>' + currentpage + '</ b> / <b>' + n + '</ b> page of each page <b>' + perpage + '</ b> Total: <b> '+ sum +' </ b> data </ td> ');
document.write ( '<td valign="middle"> <div align="right"> page:');
if (currentpage == 1)
(
document.write ( '<font face=webdings color="'+fontcolor+'"> 9 </ font>');
)
else
(
document.write ( '<a href="'+urlstr+'&page=1" title=""> <font face=webdings> 9 </ font> </ a>');
)
if (currentpage> 10)
(
document.write ( '<a href="'+urlstr+'&page='+(currentpage-10)+'" title=""> <font face=webdings> 7 </ font> </ a>' );
)
document.write ( '<b>');
for (i = pp% 10 +1; i <pp% 10 +1 +11; i + +)
(
if (i == n +1) break;
if (i == currentpage)
(
document.write ( '<font color="'+fontcolor+'">' + i + '</ font>');
)
else
(
document.write ( '<a href="'+urlstr+'&page='+i+'">' + i + '</ a>');
)
)
document.write ( '</ b>');
if (n-currentpage> 10)
(
document.write ( '<a href="'+urlstr+'&page='+(currentpage+10)+'" title=""> <font face=webdings> 8 </ font> </ a>' );
)
if (currentpage == n)
(
document.write ( '<Font face=webdings color="'+fontcolor+'">: </ font>');
)
else
(
document.write ( '<a href="'+urlstr+'&page='+n+'" title=""> <font face=webdings>: </ font> </ a>');
)

document.write ( 'Go to: <input type=text name=Page size=3 maxlength=10 value="'+currentpage+'"> <input type=submit value=Go name=submit>');
document.write ( '</ div> </ td> </ tr>');
document.write ( '</ form> </ table>');



pager.ascx.cs

namespace Web
(
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

/ / / <summary>
/ / / Pager1 summary.
/ / / </ Summary>
public class pagercontrol: System.Web.UI.UserControl
(
public string urlstr = "page.aspx";
public int pageindex = 1;
public int sum = 20;
public int perpage = 20;
public string tablewidth = "100%";
public string fontcolor = "black";
private void Page_Load (object sender, System.EventArgs e)
(
/ / Put user code here to initialize the page

)

# region Web Form Designer generated code
override protected void OnInit (EventArgs e)
(
/ /
/ / CODEGEN: This call is the ASP.NET Web Form Designer necessary.
/ /
InitializeComponent ();
base.OnInit (e);
)

/ / / <summary>
/ / / Designer to support the required method - Do not use a code editor
/ / / Modify the contents of this method.
/ / / </ Summary>
private void InitializeComponent ()
(
this.Load + = new System.EventHandler (this.Page_Load);
)
# endregion
)
)



.Net Control and components Articles


Can't Find What You're Looking For?


Rating: Not yet rated

Comments

No comments posted.