This is a very very good control . I have modified few things to make it complete.
1. Fixed ajax issue.
2. Provide an option to select page size.
Here is the modified version
User control code --
WebPager.cs
#region // using Directives
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Web;
#endregion
namespace AspNet.CustomControl
{
[ToolboxData("<{0}:WebPager runat=\"server\"></{0}:WebPager>")]
[ToolboxBitmap(typeof(resfinder), "AspNet.CustomControl.WebPager.WebPager.bmp")]
public class WebPager : WebControl, IPostBackEventHandler, INamingContainer
{
string _CssClass = "PagerContainerTable";
#region // Save/Load Control State
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Page.RegisterRequiresControlState(this);
if (!this.CssClass.IsNullOrEmpty())
{
_CssClass = this.CssClass;
base.CssClass = "";
}
else
{
EmbedCss(this.Theme.ToString() + ".css");
}
}
private void EmbedCss(string Resourcename)
{
if (Page.Header.FindControl("WebPagerStyle") == null)
{
LiteralControl css = new LiteralControl("<link href=\"" + this.GetResourceUrl("WebPager.WebPager" + Resourcename) + "\" type=\"text/css\" rel=\"stylesheet\" />");
css.ID = "WebPagerStyle";
Page.Header.Controls.Add(css);
}
}
protected override object SaveControlState()
{
object[] objState = new object[2];
objState[0] = CurrentIndex;
objState[1] = PageSize;
return objState;
}
protected override void LoadControlState(object state)
{
object[] savedState = (object[])state;
CurrentIndex = (int)savedState[0];
PageSize = (int)savedState[1];
}
#endregion
#region // PostBack Stuff
private static readonly object EventCommand = new object();
public delegate void PageSizeChangeHandler(object sender, PageSizeChangeEventArgs pageSizeChangeEventArgs);
public event PageSizeChangeHandler PageSizeChange;
public event CommandEventHandler Command
{
add { Events.AddHandler(EventCommand, value); }
remove { Events.RemoveHandler(EventCommand, value); }
}
protected virtual void OnCommand(CommandEventArgs e)
{
CommandEventHandler clickHandler = (CommandEventHandler)Events[EventCommand];
if (clickHandler != null) clickHandler(this, e);
}
void IPostBackEventHandler.RaisePostBackEvent(string eventArgument)
{
#region //PageSizeChange
if (eventArgument.Contains("PageSize##"))
{
int newPageSize = this.PageSize;
int.TryParse(eventArgument.Substring(eventArgument.LastIndexOf("##") + 2), out newPageSize);
this.CurrentIndex = 1;
if (PageSizeChange != null)
{
PageSizeChange(this, new PageSizeChangeEventArgs { CurrentPageSize = this.PageSize, NewPageSize = newPageSize });
}
this.PageSize = newPageSize;
}
#endregion
else
OnCommand(new CommandEventArgs(this.UniqueID, Convert.ToInt32(eventArgument)));
}
#endregion
#region // Accessors (Behavioural)
private double _itemCount;
[Browsable(false)]
public double ItemCount
{
get { return _itemCount; }
set
{
_itemCount = value;
double divide = ItemCount / PageSize;
double ceiled = System.Math.Ceiling(divide);
PageCount = Convert.ToInt32(ceiled);
}
}
private int _currentIndex = 1;
[Browsable(false)]
public int CurrentIndex
{
get { return _currentIndex; }
set { _currentIndex = value; }
}
private int _pageSize = 15;
[Category("Behavioural")]
public int PageSize
{
get { return _pageSize; }
set { _pageSize = value; }
}
private bool _showPageSizeSelection = false;
[Category("Behavioural")]
public bool ShowPageSizeSelection
{
get { return _showPageSizeSelection; }
set { _showPageSizeSelection = value; }
}
[Browsable(false)]
public List<int> PageSizeSelections
{
set
{
ViewState["PageSizeSelections"] = value;
}
get
{
List<int> _PageSizeSelections = new List<int>();
if (ViewState["PageSizeSelections"] == null)
{
_PageSizeSelections = new List<int>() { 10, 20, 30, 40, 50 };
}
else
{
_PageSizeSelections = ViewState["PageSizeSelections"] as List<int>;
}
return _PageSizeSelections;
}
}
private int _pageCount;
[Browsable(false)]
private int PageCount
{
get { return _pageCount; }
set { _pageCount = value; }
}
private bool _showFirstLast = false;
[Category("Behavioural")]
public bool GenerateFirstLastSection
{
get { return _showFirstLast; }
set { _showFirstLast = value; }
}
private bool _enableSSC = true;
[Category("Behavioural")]
public bool GenerateSmartShortCuts
{
get { return _enableSSC; }
set { _enableSSC = value; }
}
private double _sscRatio = 3.0D;
[Category("Behavioural")]
public double SmartShortCutRatio
{
get { return _sscRatio; }
set { _sscRatio = value; }
}
private int _maxSmartShortCutCount = 6;
[Category("Behavioural")]
public int MaxSmartShortCutCount
{
get { return _maxSmartShortCutCount; }
set { _maxSmartShortCutCount = value; }
}
private int _sscThreshold = 30;
[Category("Behavioural")]
public int SmartShortCutThreshold
{
get { return _sscThreshold; }
set { _sscThreshold = value; }
}
private int _firstCompactedPageCount = 10;
[Category("Behavioural")]
public int CompactModePageCount
{
get { return _firstCompactedPageCount; }
set { _firstCompactedPageCount = value; }
}
private int _notCompactedPageCount = 15;
[Category("Behavioural")]
public int NormalModePageCount
{
get { return _notCompactedPageCount; }
set { _notCompactedPageCount = value; }
}
private bool _altEnabled = true;
[Category("Behavioural")]
public bool GenerateToolTips
{
get { return _altEnabled; }
set { _altEnabled = value; }
}
private bool _infoCellVisible = true;
[Category("Behavioural")]
public bool GeneratePagerInfoSection
{
get { return _infoCellVisible; }
set { _infoCellVisible = value; }
}
private bool _generateGoToSection = false;
[Category("Behavioural")]
public bool GenerateGoToSection
{
get { return _generateGoToSection; }
set { _generateGoToSection = value; }
}
private bool _generateHiddenHyperlinks = false;
[Category("Behavioural")]
public bool GenerateHiddenHyperlinks
{
get { return _generateHiddenHyperlinks; }
set { _generateHiddenHyperlinks = value; }
}
private string _queryStringParameterName = "pagerControlCurrentPageIndex";
[Category("Behavioural")]
public string QueryStringParameterName
{
get { return _queryStringParameterName; }
set { _queryStringParameterName = value; }
}
#endregion
#region // Accessors (Globalization)
private string _GO = "go";
[Category("Globalization")]
public string GoClause
{
get { return _GO; }
set { _GO = value; }
}
private string _OF = "of";
[Category("Globalization")]
public string OfClause
{
get { return _OF; }
set { _OF = value; }
}
private string _FROM = "From";
[Category("Globalization")]
public string FromClause
{
get { return _FROM; }
set { _FROM = value; }
}
private string _PAGE = "Page";
[Category("Globalization")]
public string PageClause
{
get { return _PAGE; }
set { _PAGE = value; }
}
private string _TO = "to";
[Category("Globalization")]
public string ToClause
{
get { return _TO; }
set { _TO = value; }
}
private string _SHOWING_RESULT = "Showing Results";
[Category("Globalization")]
public string ShowingResultClause
{
get { return _SHOWING_RESULT; }
set { _SHOWING_RESULT = value; }
}
private string _SHOW_RESULT = "Show Result";
[Category("Globalization")]
public string ShowResultClause
{
get { return _SHOW_RESULT; }
set { _SHOW_RESULT = value; }
}
private string _BACK_TO_FIRST = "to First Page";
[Category("Globalization")]
public string BackToFirstClause
{
get { return _BACK_TO_FIRST; }
set { _BACK_TO_FIRST = value; }
}
private string _GO_TO_LAST = "to Last Page";
[Category("Globalization")]
public string GoToLastClause
{
get { return _GO_TO_LAST; }
set { _GO_TO_LAST = value; }
}
private string _BACK_TO_PAGE = "Back to Page";
[Category("Globalization")]
public string BackToPageClause
{
get { return _BACK_TO_PAGE; }
set { _BACK_TO_PAGE = value; }
}
private string _NEXT_TO_PAGE = "Next to Page";
[Category("Globalization")]
public string NextToPageClause
{
get { return _NEXT_TO_PAGE; }
set { _NEXT_TO_PAGE = value; }
}
private string _LAST = ">>";
[Category("Globalization")]
public string LastClause
{
get { return _LAST; }
set { _LAST = value; }
}
private string _FIRST = "<<";
[Category("Globalization")]
public string FirstClause
{
get { return _FIRST; }
set { _FIRST = value; }
}
private string _previous = "<";
[Category("Globalization")]
public string PreviousClause
{
get { return _previous; }
set { _previous = value; }
}
private string _next = ">";
[Category("Globalization")]
public string NextClause
{
get { return _next; }
set { _next = value; }
}
private bool _rightToLeft = false;
[Category("Globalization")]
public bool RTL
{
get { return _rightToLeft; }
set { _rightToLeft = value; }
}
[Category("Appearance"), DefaultValue(WebPagerTheme.Light), Browsable(false)]
public WebPagerTheme Theme
{
get
{
if (ViewState["WebPagerTheme"] == null)
return WebPagerTheme.Light;
else
return (WebPagerTheme)Enum.Parse(typeof(WebPagerTheme), ViewState["WebPagerTheme"].ToString());
}
set
{
if (HttpContext.Current != null)
{
ViewState["WebPagerTheme"] = value;
}
}
}
#endregion
#region // Render Utilities
private string GenerateAltMessage(int pageNumber)
{
StringBuilder altGen = new StringBuilder();
altGen.Append(pageNumber == CurrentIndex ? ShowingResultClause : ShowResultClause);
altGen.Append(" ");
altGen.Append(((pageNumber - 1) * PageSize) + 1);
altGen.Append(" ");
altGen.Append(ToClause);
altGen.Append(" ");
altGen.Append(pageNumber == PageCount ? ItemCount : pageNumber * PageSize);
altGen.Append(" ");
altGen.Append(OfClause);
altGen.Append(" ");
altGen.Append(ItemCount);
return altGen.ToString();
}
private string GetAlternativeText(int pageNumber)
{
return GenerateToolTips ? string.Format(" title=\"{0}\"", GenerateAltMessage(pageNumber)) : "";
}
private string RenderFirst()
{
string templateCell = "<td class=\"PagerOtherPageCells\"><a class=\"PagerHyperlinkStyle\" href=\"{0}\" title=\"" + " " + BackToFirstClause + " " + "\"> " + FirstClause + " </a></td>";
return String.Format(templateCell, Page.ClientScript.GetPostBackClientHyperlink(this, "1"));
}
private string RenderLast()
{
string templateCell = "<td class=\"PagerOtherPageCells\"><a class=\"PagerHyperlinkStyle\" href=\"{0}\" title=\"" + " " + GoToLastClause + " " + "\"> " + LastClause + " </a></td>";
return String.Format(templateCell, Page.ClientScript.GetPostBackClientHyperlink(this, PageCount.ToString()));
}
private string RenderBack()
{
string templateCell = "<td class=\"PagerOtherPageCells\"><a class=\"PagerHyperlinkStyle\" href=\"{0}\" title=\"" + " " + BackToPageClause + " " + (CurrentIndex - 1).ToString() + "\"> " + PreviousClause + " </a></td>";
return String.Format(templateCell, Page.ClientScript.GetPostBackClientHyperlink(this, (CurrentIndex - 1).ToString()));
}
private string RenderNext()
{
string templateCell = "<td class=\"PagerOtherPageCells\"><a class=\"PagerHyperlinkStyle\" href=\"{0}\" title=\"" + " " + NextToPageClause + " " + (CurrentIndex + 1).ToString() + "\"> " + NextClause + " </a></td>";
return String.Format(templateCell, Page.ClientScript.GetPostBackClientHyperlink(this, (CurrentIndex + 1).ToString()));
}
private string RenderCurrent()
{
return "<td class=\"PagerCurrentPageCell\"><span class=\"PagerHyperlinkStyle\" " + GetAlternativeText(CurrentIndex) + " > " + CurrentIndex.ToString() + " </span></td>";
}
private string RenderOther(int pageNumber)
{
string templateCell = "<td class=\"PagerOtherPageCells\"><a class=\"PagerHyperlinkStyle\" href=\"{0}\" " + GetAlternativeText(pageNumber) + " > " + pageNumber.ToString() + " </a></td>";
return String.Format(templateCell, Page.ClientScript.GetPostBackClientHyperlink(this, pageNumber.ToString()));
}
private string RenderSSC(int pageNumber)
{
string templateCell = "<td class=\"PagerSSCCells\"><a class=\"PagerHyperlinkStyle\" href=\"{0}\" " + GetAlternativeText(pageNumber) + " > " + pageNumber.ToString() + " </a></td>";
return String.Format(templateCell, Page.ClientScript.GetPostBackClientHyperlink(this, pageNumber.ToString()));
}
private string RenderGoTo()
{
string templateCell = "<td style=\"padding:1px 1px 1px 1px;\" class=\"PagerOtherPageCells\"><div onclick=\"handleGoToVisibility()\" class=\"GoToLabel\"> Go To </div><img id=\"goto_img\" onclick=\"handleGoToVisibility()\" src=\"" + this.GetResourceUrl("WebPager.arr_right.gif") + "\" alt=\"\" class=\"GoToArrow\"/> <div id=\"div_goto\" style=\"display:none;\"><select class=\"GoToSelect\" name=\"ddlTes\" id=\"ddlTes\" onchange=\"javascript:handleGoto(this);\">{0}</select></div></td>";
string listItemTemplate = "<option {0} value=\"{1}\">{2}</option>";
StringBuilder sb = new StringBuilder();
for (int i = 1; i <= this.PageCount; i++)
{
sb.Append(string.Format(listItemTemplate, i == CurrentIndex ? "selected=\"selected\" class=\"GoToSelectedOption\"" : "", Page.ClientScript.GetPostBackClientHyperlink(this, i.ToString()), i));
}
return string.Format(templateCell, sb.ToString());
}
private string RenderGoToScript()
{
StringBuilder sb = new StringBuilder();
sb.Append(@"
function handleGoto(selectObj) {
eval(selectObj.options[selectObj.selectedIndex].value);
}
function handleGoToVisibility() {
var gotoElem = document.getElementById('div_goto');
gotoElem.style.display = gotoElem.style.display == 'none' ? 'inline' : 'none';
var gotoImg = document.getElementById('goto_img');
");
sb.AppendFormat("gotoImg.src = gotoElem.style.display == 'none' ? '{0}' : '{1}';",
this.GetResourceUrl("WebPager.arr_right.gif"),
this.GetResourceUrl("WebPager.arr_left.gif")
);
sb.Append("}");
string goToScript = "<script type=\"text/javascript\">{0}</script>";
return string.Format(goToScript, sb.ToString());
}
private string RenderPageSizeSelection()
{
string templateCell = "<td style=\"padding:1px 1px 1px 1px;\" class=\"PagerOtherPageCells\"><div class=\"GoToLabel\"> Page size </div></td><td><div id=\"div_pagesize\"><select class=\"PageSizeSelect\" name=\"ddlTes\" id=\"ddlPageSize\" onchange=\"javascript:handleGoto(this);\">{0}</select></div></td>";
string listItemTemplate = "<option {0} value=\"{1}\">{2}</option>";
StringBuilder sb = new StringBuilder();
foreach (int i in PageSizeSelections)
{
sb.Append(string.Format(listItemTemplate, i == PageSize ? "selected=\"selected\" class=\"GoToSelectedOption\"" : "", Page.ClientScript.GetPostBackClientHyperlink(this, "PageSize##" + i.ToString()), i));
}
return string.Format(templateCell, sb.ToString());
}
#endregion
#region // Smart ShortCut Stuff
private List<int> _smartShortCutList;
private List<int> SmartShortCutList
{
get { return _smartShortCutList; }
set { _smartShortCutList = value; }
}
private void CalculateSmartShortcutAndFillList()
{
_smartShortCutList = new List<int>();
double shortCutCount = this.PageCount * SmartShortCutRatio / 100;
double shortCutCountRounded = System.Math.Round(shortCutCount, 0);
if (shortCutCountRounded > MaxSmartShortCutCount) shortCutCountRounded = MaxSmartShortCutCount;
if (shortCutCountRounded == 1) shortCutCountRounded++;
for (int i = 1; i < shortCutCountRounded + 1; i++)
{
int calculatedValue = (int)(System.Math.Round((this.PageCount * (100 / shortCutCountRounded) * i / 100) * 0.1, 0) * 10);
if (calculatedValue >= this.PageCount) break;
SmartShortCutList.Add(calculatedValue);
}
}
private void RenderSmartShortCutByCriteria(int basePageNumber, bool getRightBand, HtmlTextWriter writer)
{
if (IsSmartShortCutAvailable())
{
List<int> lstSSC = this.SmartShortCutList;
int rVal = -1;
if (getRightBand)
{
for (int i = 0; i < lstSSC.Count; i++)
{
if (lstSSC[i] > basePageNumber)
{
rVal = i;
break;
}
}
if (rVal >= 0)
{
for (int i = rVal; i < lstSSC.Count; i++)
{
if (lstSSC[i] != basePageNumber)
{
writer.Write(RenderSSC(lstSSC[i]));
}
}
}
}
else if (!getRightBand)
{
for (int i = 0; i < lstSSC.Count; i++)
{
if (basePageNumber > lstSSC[i])
{
rVal = i;
}
}
if (rVal >= 0)
{
for (int i = 0; i < rVal + 1; i++)
{
if (lstSSC[i] != basePageNumber)
{
writer.Write(RenderSSC(lstSSC[i]));
}
}
}
}
}
}
bool IsSmartShortCutAvailable()
{
return this.GenerateSmartShortCuts && this.SmartShortCutList != null && this.SmartShortCutList.Count != 0;
}
#endregion
#region // Render "SearchEngineFriendly" hyperlinks in HiddenDiv
private string RenderHiddenDiv()
{
System.Text.RegularExpressions.Regex regEx;
Uri theURL = System.Web.HttpContext.Current.Request.Url;
bool hasQueryStringParam = !string.IsNullOrEmpty(System.Web.HttpContext.Current.Request.ServerVariables["QUERY_STRING"]) ? true : false;
string tempHyperlink = "<a href=\"{0}\">page {1}</a>";
string tempDiv = "<div style=\"display:none;\">{0}</div>";
StringBuilder sb = new StringBuilder();
if (hasQueryStringParam && System.Web.HttpContext.Current.Request.QueryString[this.QueryStringParameterName] != null)
{
regEx = new Regex(this.QueryStringParameterName + @"\=\d*", RegexOptions.Compiled | RegexOptions.Singleline);
for (int i = 0; i < this.NormalModePageCount; i++)
{
sb.Append(string.Format(tempHyperlink,
regEx.Replace(theURL.ToString(), this.QueryStringParameterName + "=" + (i + this.CurrentIndex)), i + this.CurrentIndex)
);
}
}
else
{
string qsParameterName = "";
for (int i = 0; i < this.NormalModePageCount; i++)
{
qsParameterName = string.Format("{0}={1}", this.QueryStringParameterName, i + this.CurrentIndex);
sb.Append(string.Format(tempHyperlink,
hasQueryStringParam ? theURL.ToString() + "&" + qsParameterName : theURL.ToString() + "?" + qsParameterName,
i + this.CurrentIndex)
);
}
}
return string.Format(tempDiv, sb.ToString());
}
#endregion
#region // Override Control's Render operation
protected override void Render(HtmlTextWriter writer)
{
if (Page != null) Page.VerifyRenderingInServerForm(this);
if (this.PageCount > this.SmartShortCutThreshold && GenerateSmartShortCuts)
{
CalculateSmartShortcutAndFillList();
}
writer.AddAttribute(HtmlTextWriterAttribute.Id, base.ClientID);
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "3");
writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "1");
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Class, _CssClass);
if (RTL) writer.AddAttribute(HtmlTextWriterAttribute.Dir, "rtl");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
if (GeneratePagerInfoSection)
{
writer.AddAttribute(HtmlTextWriterAttribute.Class, "PagerInfoCell");
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write(PageClause + " " + CurrentIndex.ToString() + " " + OfClause + " " + PageCount.ToString());
writer.RenderEndTag();
}
if (GenerateFirstLastSection && CurrentIndex != 1)
writer.Write(RenderFirst());
if (CurrentIndex != 1)
writer.Write(RenderBack());
if (CurrentIndex < CompactModePageCount)
{
if (CompactModePageCount > PageCount) CompactModePageCount = PageCount;
for (int i = 1; i < CompactModePageCount + 1; i++)
{
if (i == CurrentIndex)
{
writer.Write(RenderCurrent());
}
else
{
writer.Write(RenderOther(i));
}
}
RenderSmartShortCutByCriteria(CompactModePageCount, true, writer);
}
else if (CurrentIndex >= CompactModePageCount && CurrentIndex < NormalModePageCount)
{
if (NormalModePageCount > PageCount) NormalModePageCount = PageCount;
for (int i = 1; i < NormalModePageCount + 1; i++)
{
if (i == CurrentIndex)
{
writer.Write(RenderCurrent());
}
else
{
writer.Write(RenderOther(i));
}
}
RenderSmartShortCutByCriteria(NormalModePageCount, true, writer);
}
else if (CurrentIndex >= NormalModePageCount)
{
int gapValue = NormalModePageCount / 2;
int leftBand = CurrentIndex - gapValue;
int rightBand = CurrentIndex + gapValue;
RenderSmartShortCutByCriteria(leftBand, false, writer);
for (int i = leftBand; (i < rightBand + 1) && i < PageCount + 1; i++)
{
if (i == CurrentIndex)
{
writer.Write(RenderCurrent());
}
else
{
writer.Write(RenderOther(i));
}
}
if (rightBand < this.PageCount)
{
RenderSmartShortCutByCriteria(rightBand, true, writer);
}
}
if (CurrentIndex != PageCount)
writer.Write(RenderNext());
if (GenerateFirstLastSection && CurrentIndex != PageCount)
writer.Write(RenderLast());
if (GenerateGoToSection)
writer.Write(RenderGoTo());
if (ShowPageSizeSelection)
writer.Write(RenderPageSizeSelection());
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
if (GenerateGoToSection)
writer.Write(RenderGoToScript());
if (GenerateHiddenHyperlinks)
writer.Write(RenderHiddenDiv());
}
#endregion
}
public enum WebPagerTheme { Dark, Light }
Event class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AspNet.CustomControl
{
public class PageSizeChangeEventArgs:EventArgs
{
public int CurrentPageSize { set; get; }
public int NewPageSize { set; get; }
}
}
Modify AssemblyInfo.cs
[assembly: WebResource("AspNet.CustomControl.Resources.WebPager.arr_left.gif", "image/gif")]
[assembly: WebResource("AspNet.CustomControl.Resources.WebPager.arr_right.gif", "image/gif")]
[assembly: WebResource("AspNet.CustomControl.Resources.WebPager.WebPagerDark.css", "text/css")]
[assembly: WebResource("AspNet.CustomControl.Resources.WebPager.WebPagerLight.css", "text/css")]
Extensions class
internal static class Extensions
{
public static string GetResourceUrl(this Control container, string ResourceName)
{
return container.Page.ClientScript.GetWebResourceUrl(container.GetType(), ("AspNet.CustomControl.Resources." + ResourceName)).Replace("&", "&");
}
}
Create a folder structure in the application
Resources --> WebPager
create two css WebPagerLight.css and WebPagerDark.css also place arr_left.gif & arr_right.gif filein the WebPager folder.
WebPagerLight.css content
.PagerContainerTable { border-right: #333333 1px solid; border-top: #333333 1px solid; border-left: #333333 1px solid; color: #d1d1e1; border-bottom: #333333 1px solid; background-color: #FFFFFF; } .PagerContainerTable .PagerInfoCell { padding-right: 6px; padding-left: 6px; padding-bottom: 3px; font: bold 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; color: #f0f1f2; padding-top: 3px; white-space: nowrap; background-color: #990000; font-weight:normal; } .PagerContainerTable .PagerInfoCell:link { color: #ffcc66; text-decoration: none; } .PagerContainerTable .PagerInfoCell:visited { color: #ffcc66; text-decoration: none; } .PagerContainerTable .PagerCurrentPageCell { color: #990000; background-color: #FFFF99; cursor:default; } .PagerContainerTable .PagerOtherPageCells { background-color: #f0f1f2; } .PagerContainerTable .PagerSSCCells { background-color: #cccccc; } .PagerContainerTable .PagerHyperlinkStyle { font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .PagerHyperlinkStyle:hover { color: #000000; text-decoration: none; font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .PagerHyperlinkStyle:link { color: #000000; text-decoration: none; font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .PagerHyperlinkStyle:visited { color: #000000; text-decoration: none; font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .PagerHyperlinkStyle:active { color: #000000; text-decoration: none; font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .GoToLabel { font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; color:#333333; cursor:pointer; font-size:65%; vertical-align:middle; display:inline; } .PagerContainerTable .GoToSelect { font-size:55%; } .PagerContainerTable .GoToSelectedOption { color:#f9f9f9; background-color:#666666; } .PagerContainerTable .GoToArrow { vertical-align:middle; cursor:pointer; } .PageSizeSelect{font-size:10px;}
WebPagerDark.css content
.PagerContainerTable { border-right: #333333 1px solid; border-top: #333333 1px solid; border-left: #333333 1px solid; color: #d1d1e1; border-bottom: #333333 1px solid; background-color: #000000; } .PagerContainerTable .PagerInfoCell { padding-right: 6px; padding-left: 6px; padding-bottom: 3px; font: bold 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; color: #ffcc66; padding-top: 3px; white-space: nowrap; background-color: #001b52; font-weight:normal; } .PagerContainerTable .PagerInfoCell:link { color: #ffcc66; text-decoration: none; } .PagerContainerTable .PagerInfoCell:visited { color: #ffcc66; text-decoration: none; } .PagerContainerTable .PagerCurrentPageCell { color: #ffffff; background-color: #333333; } .PagerContainerTable .PagerOtherPageCells { color: #ffffff; background-color: #222222; } .PagerContainerTable .PagerSSCCells { background-color: #444444; } .PagerContainerTable .PagerHyperlinkStyle { font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .PagerHyperlinkStyle:hover { color: #ffcc66; text-decoration: none; font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .PagerHyperlinkStyle:link { color: #ffcc66; text-decoration: none; font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .PagerHyperlinkStyle:visited { color: #ffcc66; text-decoration: none; font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .PagerHyperlinkStyle:active { color: #ffcc66; text-decoration: none; font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; } .PagerContainerTable .GoToLabel { font: 11px arial, verdana, geneva, lucida, 'lucida grande' , arial, helvetica, sans-serif; color:#f9f9f9; cursor:pointer; font-size:65%; vertical-align:middle; display:inline; } .PagerContainerTable .GoToSelect { font-size:55%; } .PagerContainerTable .GoToSelectedOption { color:#f9f9f9; background-color:#666666; } .PagerContainerTable .GoToArrow { vertical-align:middle; cursor:pointer; } .PageSizeSelect{font-size:10px;}
Dont foget to add allthose css and image file as embaded resources.
Finally build the Application
Apply the control in asp.net page
<mom:WebPager ID="pager1" runat="server" EnableViewState="false" Theme="Light" OnCommand="pager_Command" onpagesizechange="WebPager1_PageSizeChange"
GenerateFirstLastSection="True" GenerateGoToSection="True" GenerateHiddenHyperlinks="False" ShowPageSizeSelection="true" />
code behind
public void pager_Command(object sender, CommandEventArgs e)
{
int currnetPageIndx = Convert.ToInt32(e.CommandArgument);
pager1.CurrentIndex = currnetPageIndx;
BindRepeater();
}
protected void WebPager1_PageSizeChange(object sender, MomentumInfotech.CustomControl.PageSizeChangeEventArgs pageSizeChangeEventArgs)
{
lblNewPageSize.Text = "NewPageSize - " + pageSizeChangeEventArgs.NewPageSize + " , CurrentPageSize" + pageSizeChangeEventArgs.CurrentPageSize;
pager1.PageSize = pageSizeChangeEventArgs.NewPageSize;
BindRepeater();
}
For live preview please visit
http://www.justpunjab.com/BusinessSearchResult.aspx
Thank you.
Sumanta Chatterjee
|