/// <summary> /// 呈现索引部分 /// </summary> /// <param name="output">HtmlTextWriter</param> /// <param name="selectedPageNumberColor">当前选中页码的颜色</param> public void RenderPageIndexContent(HtmlTextWriter output) { PageJump pageJump = this.PageJump; if (pageJump.Visiable) { switch (pageJump.PageJumpType) { //使用输入框输入页码跳转 case PageJumpType.TextBox: output.Write(pageJump.LeftText + " "); output.AddStyleAttribute(HtmlTextWriterStyle.Color, this.SelectedPageNumberColor); output.AddStyleAttribute("text-align", "center"); if (tbJumpIndex != null) { tbJumpIndex.Style.Add("width", "20px"); tbJumpIndex.Style.Add("height", "14px"); tbJumpIndex.Style.Add("line-height", "14px"); tbJumpIndex.RenderControl(output); } output.Write(" " + pageJump.RightText + " "); if (btnJump != null) { btnJump.RenderControl(output); } output.Write(" "); break; //下拉列表框跳转 case PageJumpType.DropDownList: output.Write(" "); // 左边文字 output.Write(pageJump.LeftText); ddlJumpIndex.RenderControl(output); // 右边文字 output.Write(pageJump.RightText); output.Write(" "); break; } } }
protected override void Render(HtmlTextWriter output) { #region ======= 外层标记 - <SPAN>...</SPAN> ======= string height = this.Height.ToString() + "pt"; LiteralControl lc = new LiteralControl(); lc.Text = "aaaa"; this.CreateChildControls(); this.Controls.Add(lc); // 外层标记 - <SPAN>...</SPAN> output.AddStyleAttribute(HtmlTextWriterStyle.Color, this.PagerFontColor); output.AddStyleAttribute(HtmlTextWriterStyle.FontFamily, this.PagerFontFamily); output.AddStyleAttribute(HtmlTextWriterStyle.FontSize, this.PagerFontSize); output.RenderBeginTag(HtmlTextWriterTag.Span); //当前页是否显示 PageJump pageJump = this.PageJump; if (pageJump.CurrentPageVisiable == true) { writeHtml += this.PageIndex.ToString() + " / " + this.PageCount.ToString() + " 页 "; } output.Write(writeHtml); #endregion #region ======= 首页 ======= // 首页 if (this.FirstPageDescription.Trim() != "" && this.FirstPageDescription != null && lbFirst != null && this.PageIndex > 1) { output.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, "none"); output.AddStyleAttribute(HtmlTextWriterStyle.Color, this.PagerFontColor); output.Write(this.PagerLeftText); lbFirst.RenderControl(output); output.Write(this.PagerRightText); output.Write(" "); } #endregion #region ======= 上一页 ======= // 上一页 if (this.FirstPageDescription.Trim() != "" && this.FirstPageDescription != null && lbPrevious != null && this.PageIndex > 1) { output.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, "none"); output.AddStyleAttribute(HtmlTextWriterStyle.Color, this.PagerFontColor); output.Write(this.PagerLeftText); lbPrevious.RenderControl(output); output.Write(this.PagerRightText); output.Write(" "); } #endregion #region ======= 前翻 ======= // 如果是前 ShowPageNumberCount 页则不显示“前翻” if (this.PageUpDescription.Trim() != "" && this.PageUpDescription != null && lbPreBatch != null && this.PageIndex > this.ShowPageNumberCount) { output.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, "none"); output.AddStyleAttribute(HtmlTextWriterStyle.Color, this.PagerFontColor); output.Write(this.PagerLeftText); lbPreBatch.RenderControl(output); output.Write(this.PagerRightText); output.Write(" "); } #endregion #region ======= 数字页码 ======= // 呈现页码部分 this.RenderPageNumber(output); #endregion #region ======= 后翻 ======= if (this.PageDownDescription.Trim() != "" && this.PageDownDescription != null && lbNextBatch != null && (this.PageCount >= (this.PageIndex + this.ShowPageNumberCount))) { output.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, "none"); output.AddStyleAttribute(HtmlTextWriterStyle.Color, this.PagerFontColor); output.Write(this.PagerLeftText); lbNextBatch.RenderControl(output); output.Write(this.PagerRightText); output.Write(" "); } #endregion #region ======= 下一页 ======= if (this.LastPageDescription.Trim() != "" && this.LastPageDescription != null && lbNext != null && this.PageIndex < this.PageCount) { output.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, "none"); output.AddStyleAttribute(HtmlTextWriterStyle.Color, this.PagerFontColor); output.Write(this.PagerLeftText); lbNext.RenderControl(output); output.Write(this.PagerRightText); output.Write(" "); } #endregion #region ======= 末页 ======= // 末页 if (this.LastPageDescription.Trim() != "" && this.LastPageDescription != null && lbLast != null && this.PageIndex < this.PageCount) { output.AddStyleAttribute(HtmlTextWriterStyle.TextDecoration, "none"); output.AddStyleAttribute(HtmlTextWriterStyle.Color, this.PagerFontColor); output.Write(this.PagerLeftText); lbLast.RenderControl(output); output.Write(this.PagerRightText); output.Write(" "); } #endregion #region ======= 索引跳转 ======= // 呈现索引跳转 this.RenderPageIndexContent(output); #endregion #region =======每页显示行数跳转======= // 呈现每页显示行数跳转 this.RenderPageNumJump(output); #endregion =======每页显示行数跳转======= output.RenderEndTag(); }