private int _cnt; public int start; private int _page; private int _limit; public string uri; public string template_next; public string template_prev; public string template_page; public string template_this; public string template_delim; // constructor public Pager () { _cnt = 0; //_skip = 0; start = 0; _page = 1; _limit = 999; uri = ""; template_next = ">"; template_prev = "<"; template_page = "%PAGE%"; template_this = "%PAGE%"; template_delim = "\n"; } // html (output) public string html () { string htmlo = ""; int start = 1; int tpages = this.total_pages(); int page = this._page; // previous if (page > 1) { string tmp = ""; int prev = page - 1; tmp = this.template_prev; tmp = Regex.Replace(tmp, "%URI%", this.uri); tmp = Regex.Replace(tmp, "%PAGE%", Convert.ToString(prev)); htmlo += tmp + this.template_delim; } // page list for (int p = start; p <= tpages; p++) { string tmp = ""; if (p == page) { tmp = this.template_this; tmp = Regex.Replace(tmp, "%URI%", this.uri); tmp = Regex.Replace(tmp, "%PAGE%", Convert.ToString(p)); } else { tmp = this.template_page; tmp = Regex.Replace(tmp, "%URI%", this.uri); tmp = Regex.Replace(tmp, "%PAGE%", Convert.ToString(p)); } htmlo += tmp + this.template_delim; } // next if (page < tpages) { string tmp = ""; int next = page + 1; tmp = this.template_next; tmp = Regex.Replace(tmp, "%URI%", this.uri); tmp = Regex.Replace(tmp, "%PAGE%", Convert.ToString(next)); htmlo += tmp; } return htmlo; } // cnt public object cnt { get { return this._cnt; } set { this._cnt = Convert.ToInt32((object) value); } } // page public object page { get { return this._page; } set { this._page = Convert.ToInt32((object) value); } } // skip public int skip { get { return ((int)this.limit * (int)this.page) - (int)this.limit; } } // limit public object limit { get { return this._limit; } set { this._limit = Convert.ToInt32((object) value); } } // total_pages public int total_pages () { int praw = 0; int p = 0; if (this._cnt > 0) { praw = this._cnt / this._limit; } p = Convert.ToInt32(praw) == praw ? praw : Convert.ToInt32(praw) + 1; return p; } }