public string ToHtmlString() { TagBuilder buttonTag = new TagBuilder(Tag.ToString()); buttonTag.AddCssClass("k-button k-button-icontext td-grid-button"); if (CssClass.HasValue()) { buttonTag.AddCssClass(CssClass.Trim()); } if (Name.HasValue()) { buttonTag.MergeAttribute("name", Name); buttonTag.GenerateId(Name); } if (Title.HasValue()) { buttonTag.MergeAttribute("title", Title); } if (Tag == ButtonTag.a) { buttonTag.MergeAttribute("href", Url.HasValue() ? Url : "javascript: void(0)"); } if (HtmlAttributes.Count > 0) { buttonTag.MergeAttributes(HtmlAttributes); } var imageTag = new TagBuilder("span"); imageTag.AddCssClass("k-icon td-grid-button-image"); if (ImageCssClass.HasValue()) { imageTag.AddCssClass(ImageCssClass); } buttonTag.InnerHtml = imageTag.ToString(); return(buttonTag.ToString()); }
public override string ToString() { if (PageCount <= 1) { return(""); } int curPage = PageCurrent + 1; var pages = new List <string>(); // handle simplest case first: only a few pages! if (PageCount <= _cellcount) { for (int i = 1; i <= PageCount; i++) { pages.Add(i.ToString()); } } else { if (curPage < _cellcount - 1) { // we're near the start for (int i = 1; i < _cellcount; i++) { pages.Add(i.ToString()); } pages.Add(PAGER_DOTS); pages.Add(PageCount.ToString()); } else if (curPage > PageCount - _cellcount + 2) { // we're near the end pages.Add("1"); pages.Add(PAGER_DOTS); for (int i = PageCount - _cellcount + 2; i <= PageCount; i++) { pages.Add(i.ToString()); } } else { // we're in the middle, somewhere pages.Add("1"); pages.Add(PAGER_DOTS); int range = _cellcount - 4; for (int i = curPage - range; i <= curPage + range; i++) { pages.Add(i.ToString()); } pages.Add(PAGER_DOTS); pages.Add(PageCount.ToString()); } } var sb = new StringBuilder(1024); if (CssClass.HasValue() || DivId.HasValue()) { sb.Append("<div "); if (DivId.HasValue()) { sb.Append("id=\""); sb.Append(DivId); sb.Append("\" "); } if (CssClass.HasValue()) { sb.Append("class=\""); sb.Append(CssClass); sb.Append("\" "); } sb.AppendLine(">"); } if (curPage > 1) { WriteCell(sb, _prev, "page-numbers"); } foreach (string page in pages) { WriteCell(sb, page, "page-numbers"); } if (curPage < PageCount) { WriteCell(sb, _next, "page-numbers"); } if (CssClass.HasValue() || DivId.HasValue()) { sb.AppendLine("</div>"); } return(sb.ToString()); }