static string LastPage <T>(EntityPage <T> page) { if (page.PageIndex != page.PageCount) { return(string.Format("<div onclick=\"_DoPage({1});\">{0}</div>", page.LastButton.ToHtmlString(), page.PageCount)); } else { return(string.Format("<div>{0}</div>", page.LastButton.ToHtmlString())); } }
static string PrePage <T>(EntityPage <T> page) { if (page.PageIndex > 1) { return(string.Format("<div onclick=\"_DoPage({1});\">{0}</div>", page.PreButton.ToHtmlString(), page.PageIndex - 1)); } else { return(string.Format("<div>{0}</div>", page.PreButton.ToHtmlString())); } }
static string FirstPage <T>(EntityPage <T> page) { if (page.PageIndex > 0) { return(string.Format("<div onclick=\"_DoPage(1);\">{0}</div>", page.FirstButton.ToHtmlString())); } else { return(string.Format("<div>{0}</div>", page.FirstButton.ToHtmlString())); } }
public static MvcHtmlString Pager <T>(this HtmlHelper htmlHelper, EntityPage <T> EntityPage, string ScriptFunctionName) { StringBuilder sb = new StringBuilder(); sb.Append(Script(ScriptFunctionName)); sb.Append(FirstPage(EntityPage)); sb.Append(PrePage(EntityPage)); sb.Append(NextPage(EntityPage)); sb.Append(LastPage(EntityPage)); sb.Append(PageCountLabel(EntityPage)); sb.Append(RecordCountLabel(EntityPage)); return(new MvcHtmlString(sb.ToString())); }
static string RecordCountLabel <T>(EntityPage <T> page) { return(string.Format("{0}{1}{2}", page.RecordCountLabelBefor.ToHtmlString(), page.RecordCount.ToString(), page.RecordCountLabelAfter.ToHtmlString())); }
static string PageCountLabel <T>(EntityPage <T> page) { return(string.Format("<div>{0}{1}/{2}{3}</div>", page.PageIndexLabelBefore.ToHtmlString(), page.PageIndex.ToString(), page.PageCount.ToString(), page.PageIndexLabelAfter.ToHtmlString())); }