You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1215 lines
56 KiB
1215 lines
56 KiB
|
|
using System;
|
|
using System.ComponentModel;
|
|
using System.Text;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Web;
|
|
using System.Security.Permissions;
|
|
using System.Text.RegularExpressions;
|
|
using System.Collections.Specialized;
|
|
using System.IO;
|
|
namespace OT.Controls.DataPager
|
|
{
|
|
#region AspNetPager Server Control
|
|
|
|
[AspNetHostingPermission(SecurityAction.Demand, Level = AspNetHostingPermissionLevel.Minimal)]
|
|
[DefaultProperty("PageSize")]
|
|
[DefaultEvent("PageChanged")]
|
|
[ParseChildren(false)]
|
|
[PersistChildren(false)]
|
|
[Designer(typeof(PagerDesigner))]
|
|
[ToolboxData("<{0}:Pager runat=server></{0}:Pager>")]
|
|
public partial class Pager : Panel, INamingContainer, IPostBackEventHandler, IPostBackDataHandler
|
|
{
|
|
|
|
#region Control Rendering Logic
|
|
|
|
protected override void OnInit(EventArgs e)
|
|
{
|
|
base.OnInit(e);
|
|
if (null != CloneFrom && string.Empty != CloneFrom.Trim())
|
|
{
|
|
Pager ctrl = Parent.FindControl(CloneFrom) as Pager;
|
|
if (null == ctrl)
|
|
{
|
|
string errStr = "The control \" %controlID% \" does not exist or is not of type Wuqi.Webdiyer.AspNetPager!";
|
|
throw new ArgumentException(errStr.Replace("%controlID%", CloneFrom), "CloneFrom");
|
|
}
|
|
if (null != ctrl.cloneFrom && this == ctrl.cloneFrom)
|
|
{
|
|
string errStr = "Invalid value for the CloneFrom property, AspNetPager controls can not to be cloned recursively!";
|
|
throw new ArgumentException(errStr, "CloneFrom");
|
|
}
|
|
cloneFrom = ctrl;
|
|
CssClass = cloneFrom.CssClass;
|
|
Width = cloneFrom.Width;
|
|
Height = cloneFrom.Height;
|
|
HorizontalAlign = cloneFrom.HorizontalAlign;
|
|
BackColor = cloneFrom.BackColor;
|
|
BackImageUrl = cloneFrom.BackImageUrl;
|
|
BorderColor = cloneFrom.BorderColor;
|
|
BorderStyle = cloneFrom.BorderStyle;
|
|
BorderWidth = cloneFrom.BorderWidth;
|
|
Font.CopyFrom(cloneFrom.Font);
|
|
ForeColor = cloneFrom.ForeColor;
|
|
EnableViewState = cloneFrom.EnableViewState;
|
|
Enabled = cloneFrom.Enabled;
|
|
}
|
|
}
|
|
|
|
protected override void OnLoad(EventArgs e)
|
|
{
|
|
if (UrlPaging)
|
|
{
|
|
currentUrl = Page.Request.Path;
|
|
queryString = Page.Request.ServerVariables["Query_String"];
|
|
if (!Page.IsPostBack && cloneFrom == null)
|
|
{
|
|
int index;
|
|
int.TryParse(Page.Request.QueryString[UrlPageIndexName], out index);
|
|
if (index <= 0)
|
|
index = 1;
|
|
else if (ReverseUrlPageIndex)
|
|
index = PageCount - index + 1;
|
|
PageChangingEventArgs args = new PageChangingEventArgs(index);
|
|
OnPageChanging(args);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
inputPageIndex = Page.Request.Form[UniqueID + "_input"];
|
|
}
|
|
base.OnLoad(e);
|
|
}
|
|
|
|
protected override void OnPreRender(EventArgs e)
|
|
{
|
|
if (PageCount > 1)
|
|
{
|
|
if ((ShowPageIndexBox == ShowPageIndexBox.Always) || (ShowPageIndexBox == ShowPageIndexBox.Auto && PageCount >= ShowBoxThreshold))
|
|
{
|
|
StringBuilder sb = new StringBuilder("<script language=\"Javascript\" type=\"text/javascript\"><!--\n");
|
|
if (UrlPaging)
|
|
{
|
|
sb.Append("function ANP_goToPage(boxEl){if(boxEl!=null){var pi;if(boxEl.tagName==\"SELECT\")");
|
|
sb.Append("{pi=boxEl.options[boxEl.selectedIndex].value;}else{pi=boxEl.value;}");
|
|
if (string.IsNullOrEmpty(UrlPagingTarget))
|
|
sb.Append("location.href=\"").Append(GetHrefString(-1)).Append("\"");
|
|
else
|
|
sb.Append("window.open(\"").Append(GetHrefString(-1)).Append("\",\"").Append(UrlPagingTarget).Append("\")");
|
|
sb.Append(";}}\n");
|
|
}
|
|
if (PageIndexBoxType == PageIndexBoxType.TextBox)
|
|
{
|
|
string ciscript = " function ANP_checkInput(bid, mv) {";
|
|
ciscript += " var el = document.getElementById(bid);";
|
|
ciscript += " var r = new RegExp(\"^\\s*(\\d+)\\s*$\");";
|
|
ciscript += " if (r.test(el.value)) {";
|
|
ciscript += " if (RegExp.$1 < 1 || RegExp.$1 > mv) {";
|
|
ciscript += " alert(\"頁碼超出有效範圍!\"); el.focus(); el.select(); return false;";
|
|
ciscript += " }";
|
|
ciscript += " alert(\"頁碼不是有效數字!\");";
|
|
ciscript += " el.focus();";
|
|
ciscript += " el.select();";
|
|
ciscript += " return false;";
|
|
ciscript += " }";
|
|
ciscript += " return true; ";
|
|
ciscript += " }";
|
|
if (ciscript != null)
|
|
{
|
|
ciscript = ciscript.Replace("%PageIndexOutOfRangeErrorMessage%", PageIndexOutOfRangeErrorMessage);
|
|
ciscript = ciscript.Replace("%InvalidPageIndexErrorMessage%", InvalidPageIndexErrorMessage);
|
|
}
|
|
sb.Append(ciscript).Append("\n");
|
|
string keyScript = "function ANP_keydown(e,btnId){var kcode;if(window.event){kcode=e.keyCode;}else if(e.which){kcode=e.which;}var validKey=(kcode==8||kcode==46||kcode==37||kcode==39||(kcode>=48&&kcode<=57)||(kcode>=96&&kcode<=105));if(!validKey){if(kcode==13) document.getElementById(btnId).click();if(e.preventDefault) e.preventDefault();else{event.returnValue=false};}}";
|
|
sb.Append(keyScript);
|
|
}
|
|
sb.Append("\n--></script>");
|
|
Type ctype = GetType();
|
|
ClientScriptManager cs = Page.ClientScript;
|
|
if (!cs.IsClientScriptBlockRegistered(ctype, "anp_script"))
|
|
cs.RegisterClientScriptBlock(ctype, "anp_script", sb.ToString());
|
|
}
|
|
}
|
|
base.OnPreRender(e);
|
|
}
|
|
|
|
protected override void AddAttributesToRender(HtmlTextWriter writer)
|
|
{
|
|
if (Page != null && !UrlPaging)
|
|
Page.VerifyRenderingInServerForm(this);
|
|
base.AddAttributesToRender(writer);
|
|
}
|
|
|
|
public override void RenderBeginTag(HtmlTextWriter writer)
|
|
{
|
|
bool showPager = (PageCount > 1 || (PageCount <= 1 && AlwaysShow));
|
|
if (showPager)
|
|
{
|
|
base.RenderBeginTag(writer);
|
|
}
|
|
}
|
|
|
|
public override void RenderEndTag(HtmlTextWriter writer)
|
|
{
|
|
if (PageCount > 1 || (PageCount <= 1 && AlwaysShow))
|
|
base.RenderEndTag(writer);
|
|
}
|
|
|
|
|
|
protected override void RenderContents(HtmlTextWriter writer)
|
|
{
|
|
if (PageCount <= 1 && !AlwaysShow)
|
|
return;
|
|
writer.Indent = 0;
|
|
if (ShowCustomInfoSection != ShowCustomInfoSection.Never)
|
|
{
|
|
if (LayoutType == LayoutType.Table)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Style, Style.Value);
|
|
if (Height != Unit.Empty)
|
|
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, Height.ToString());
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Table); //<table>
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Tr); //<tr>
|
|
}
|
|
if (ShowCustomInfoSection == ShowCustomInfoSection.Left)
|
|
{
|
|
RenderCustomInfoSection(writer);
|
|
RenderNavigationSection(writer);
|
|
}
|
|
else
|
|
{
|
|
RenderNavigationSection(writer);
|
|
RenderCustomInfoSection(writer);
|
|
}
|
|
if (LayoutType == LayoutType.Table)
|
|
{
|
|
writer.RenderEndTag(); //</tr>
|
|
writer.RenderEndTag(); //</table>
|
|
}
|
|
}
|
|
else
|
|
RenderPagingElements(writer);
|
|
}
|
|
|
|
|
|
private void RenderPagingElements(HtmlTextWriter writer)
|
|
{
|
|
int pageIndex = 1;
|
|
try
|
|
{
|
|
pageIndex = ((this.CurrentPageIndex - 1) / this.NumericButtonCount) * this.NumericButtonCount;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
|
|
if ((this.PageCount > this.NumericButtonCount) && (this.CurrentPageButtonPosition != PagingButtonPosition.Fixed))
|
|
{
|
|
switch (this.CurrentPageButtonPosition)
|
|
{
|
|
case PagingButtonPosition.Beginning:
|
|
pageIndex = this.CurrentPageIndex - 1;
|
|
if ((pageIndex + this.NumericButtonCount) > this.PageCount)
|
|
{
|
|
pageIndex = this.PageCount - this.NumericButtonCount;
|
|
}
|
|
break;
|
|
|
|
case PagingButtonPosition.End:
|
|
if (this.CurrentPageIndex > this.NumericButtonCount)
|
|
{
|
|
pageIndex = this.CurrentPageIndex - this.NumericButtonCount;
|
|
}
|
|
break;
|
|
|
|
case PagingButtonPosition.Center:
|
|
{
|
|
int num2 = this.CurrentPageIndex - ((int)Math.Ceiling((double)(((double)this.NumericButtonCount) / 2.0)));
|
|
if (num2 > 0)
|
|
{
|
|
pageIndex = num2;
|
|
if (pageIndex > (this.PageCount - this.NumericButtonCount))
|
|
{
|
|
pageIndex = this.PageCount - this.NumericButtonCount;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
int num3 = ((pageIndex + this.NumericButtonCount) > this.PageCount) ? this.PageCount : (pageIndex + this.NumericButtonCount);
|
|
//Add By Gary 20140328 START
|
|
if (this.RecordCount > 0)
|
|
{
|
|
writer.Write("<p class=\"left t-blue02\">共 " + String.Format("{0:0,0}", RecordCount) + " 筆</p>");
|
|
}
|
|
//Add By Gary 20140328 END
|
|
if (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)
|
|
{
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Ul);
|
|
}
|
|
if ((this.NavigationButtonsPosition == NavigationButtonPosition.Left) || (this.NavigationButtonsPosition == NavigationButtonPosition.BothSides))
|
|
{
|
|
this.CreateNavigationButton(writer, NavigationButton.First);
|
|
this.CreateNavigationButton(writer, NavigationButton.Prev);
|
|
if (this.NavigationButtonsPosition == NavigationButtonPosition.Left)
|
|
{
|
|
this.CreateNavigationButton(writer, NavigationButton.Next);
|
|
this.CreateNavigationButton(writer, NavigationButton.Last);
|
|
}
|
|
}
|
|
if (this.AlwaysShowFirstLastPageNumber && (pageIndex > 1))
|
|
{
|
|
this.CreateNumericButton(writer, 1);
|
|
}
|
|
if (this.ShowMoreButtons && (pageIndex > 0))
|
|
{
|
|
this.CreateMoreButton(writer, pageIndex);
|
|
}
|
|
if (this.ShowPageIndex)
|
|
{
|
|
for (int i = pageIndex + 1; i <= num3; i++)
|
|
{
|
|
this.CreateNumericButton(writer, i);
|
|
}
|
|
}
|
|
if ((this.ShowMoreButtons && (this.PageCount > this.NumericButtonCount)) && (num3 < this.PageCount))
|
|
{
|
|
this.CreateMoreButton(writer, num3 + 1);
|
|
}
|
|
if (this.AlwaysShowFirstLastPageNumber && (num3 < this.PageCount))
|
|
{
|
|
this.CreateNumericButton(writer, this.PageCount);
|
|
}
|
|
if ((this.NavigationButtonsPosition == NavigationButtonPosition.Right) || (this.NavigationButtonsPosition == NavigationButtonPosition.BothSides))
|
|
{
|
|
if (this.NavigationButtonsPosition == NavigationButtonPosition.Right)
|
|
{
|
|
this.CreateNavigationButton(writer, NavigationButton.First);
|
|
this.CreateNavigationButton(writer, NavigationButton.Prev);
|
|
}
|
|
this.CreateNavigationButton(writer, NavigationButton.Next);
|
|
this.CreateNavigationButton(writer, NavigationButton.Last);
|
|
}
|
|
if (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)
|
|
{
|
|
writer.RenderEndTag();
|
|
}
|
|
if ((this.ShowPageIndexBox == ShowPageIndexBox.Always) || ((this.ShowPageIndexBox == ShowPageIndexBox.Auto) && (this.PageCount >= this.ShowBoxThreshold)))
|
|
{
|
|
string str = this.UniqueID + "_input";
|
|
writer.Write(" ");
|
|
if (!string.IsNullOrEmpty(this.TextBeforePageIndexBox))
|
|
{
|
|
writer.Write(this.TextBeforePageIndexBox);
|
|
}
|
|
if (this.PageIndexBoxType == PageIndexBoxType.TextBox)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");
|
|
//writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "30px"); //右邊輸入頁數input 改用自定義寬度樣式 Modify By Ted 2014/07/30
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Value, this.CurrentPageIndex.ToString());
|
|
if (!string.IsNullOrEmpty(this.PageIndexBoxStyle))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Style, this.PageIndexBoxStyle);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.PageIndexBoxClass))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.PageIndexBoxClass);
|
|
}
|
|
if (!this.Enabled || ((this.PageCount <= 1) && this.AlwaysShow))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
|
|
}
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Name, str);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Id, str);
|
|
string str2 = string.Concat(new object[] { "ANP_checkInput('", str, "',", this.PageCount, ")" });
|
|
string str3 = "ANP_keydown(event,'" + this.UniqueID + "_btn');";
|
|
string str4 = "if(" + str2 + "){ANP_goToPage(document.getElementById('" + str + "'));};return false;";
|
|
writer.AddAttribute("onkeydown", str3);
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Input);
|
|
writer.RenderEndTag();
|
|
if (!string.IsNullOrEmpty(this.TextAfterPageIndexBox))
|
|
{
|
|
writer.Write(this.TextAfterPageIndexBox);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.SubmitButtonImageUrl))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Type, "image");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Src, this.SubmitButtonImageUrl);
|
|
}
|
|
else
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Type, this.UrlPaging ? "button" : "submit");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Value, this.SubmitButtonText);
|
|
}
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.UniqueID + "_btn");
|
|
if (!string.IsNullOrEmpty(this.SubmitButtonClass))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.SubmitButtonClass);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.SubmitButtonStyle))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Style, this.SubmitButtonStyle);
|
|
}
|
|
if (!this.Enabled || ((this.PageCount <= 1) && this.AlwaysShow))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
|
|
}
|
|
writer.AddAttribute("showwaiting", "");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Onclick, this.UrlPaging ? str4 : ("if(" + str2 + "){" + this.Page.ClientScript.GetPostBackEventReference(this, null) + "} else{return false}"));
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Input);
|
|
writer.RenderEndTag();
|
|
}
|
|
else
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Name, str);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Id, str);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Onchange, this.UrlPaging ? "ANP_goToPage(this)" : this.Page.ClientScript.GetPostBackEventReference(this, null));
|
|
if (!string.IsNullOrEmpty(this.PageIndexBoxStyle))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Style, this.PageIndexBoxStyle);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.PageIndexBoxClass))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.PageIndexBoxClass);
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Select);
|
|
if (this.PageCount > 80)
|
|
{
|
|
if (this.CurrentPageIndex <= 15)
|
|
{
|
|
this.listPageIndices(writer, 1, 15);
|
|
addMoreListItem(writer, 0x10);
|
|
this.listPageIndices(writer, this.PageCount - 4, this.PageCount);
|
|
}
|
|
else if (this.CurrentPageIndex >= (this.PageCount - 14))
|
|
{
|
|
this.listPageIndices(writer, 1, 5);
|
|
addMoreListItem(writer, this.PageCount - 15);
|
|
this.listPageIndices(writer, this.PageCount - 14, this.PageCount);
|
|
}
|
|
else
|
|
{
|
|
this.listPageIndices(writer, 1, 5);
|
|
addMoreListItem(writer, this.CurrentPageIndex - 6);
|
|
this.listPageIndices(writer, this.CurrentPageIndex - 5, this.CurrentPageIndex + 5);
|
|
addMoreListItem(writer, this.CurrentPageIndex + 6);
|
|
this.listPageIndices(writer, this.PageCount - 4, this.PageCount);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.listPageIndices(writer, 1, this.PageCount);
|
|
}
|
|
writer.RenderEndTag();
|
|
if (!string.IsNullOrEmpty(this.TextAfterPageIndexBox))
|
|
{
|
|
writer.Write(this.TextAfterPageIndexBox);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CreateMoreButton(HtmlTextWriter writer, int pageIndex)
|
|
{
|
|
this.AddClassAndStyle(this.MoreButtonsClass, this.MoreButtonsStyle, writer);
|
|
this.AddPagingButtonLayoutTag(writer);
|
|
this.writeSpacingStyle(writer);
|
|
if (this.Enabled)
|
|
{
|
|
writer.AddAttribute("href", this.GetHrefString(pageIndex), false);
|
|
this.AddToolTip(writer, pageIndex);
|
|
this.AddHyperlinkTarget(writer);
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
if (this.MoreButtonType == PagingButtonType.Image)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + "more" + this.ButtonImageNameExtension + this.ButtonImageExtension);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Img);
|
|
writer.RenderEndTag();
|
|
}
|
|
else if (this.MoreButtonType == PagingButtonType.Button)
|
|
{
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + "more" + this.ButtonImageNameExtension + this.ButtonImageExtension);
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Type, "button");
|
|
writer.RenderEndTag();
|
|
}
|
|
else
|
|
{
|
|
writer.Write("...");
|
|
}
|
|
writer.RenderEndTag();
|
|
if (this.PagingButtonLayoutType != PagingButtonLayoutType.None)
|
|
{
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
|
|
private void AddClassAndStyle(string clsname, string style, HtmlTextWriter writer)
|
|
{
|
|
if (!string.IsNullOrEmpty(clsname))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Class, clsname);
|
|
}
|
|
if (!string.IsNullOrEmpty(style))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Style, style);
|
|
}
|
|
}
|
|
|
|
private void AddPagingButtonLayoutTag(HtmlTextWriter writer)
|
|
{
|
|
if (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)
|
|
{
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Li);
|
|
}
|
|
else if (this.PagingButtonLayoutType == PagingButtonLayoutType.Span)
|
|
{
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
}
|
|
}
|
|
|
|
private void CreateNumericImages(HtmlTextWriter writer, int index, bool isCurrent)
|
|
{
|
|
this.AddPagingButtonLayoutTag(writer);
|
|
string str = index.ToString();
|
|
for (int i = 0; i < str.Length; i++)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Src, string.Concat(new object[] { this.ImagePath, str[i], isCurrent ? this.CpiButtonImageNameExtension : this.ButtonImageNameExtension, this.ButtonImageExtension }));
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Img);
|
|
writer.RenderEndTag();
|
|
}
|
|
if (this.PagingButtonLayoutType != PagingButtonLayoutType.None)
|
|
{
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
|
|
private void AddHyperlinkTarget(HtmlTextWriter writer)
|
|
{
|
|
if (!string.IsNullOrEmpty(this.UrlPagingTarget))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Target, this.UrlPagingTarget);
|
|
}
|
|
}
|
|
|
|
private void AddToolTip(HtmlTextWriter writer, int pageIndex)
|
|
{
|
|
if (this.ShowNavigationToolTip)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Title, string.Format(this.NavigationToolTipTextFormatString, pageIndex));
|
|
}
|
|
}
|
|
private void CreateNumericButton(HtmlTextWriter writer, int index)
|
|
{
|
|
bool flag = index == this.CurrentPageIndex;
|
|
if ((!flag && (this.PagingButtonLayoutType != PagingButtonLayoutType.None)) || (flag && (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)))
|
|
{
|
|
if (!flag)
|
|
{
|
|
this.AddClassAndStyle(this.PagingButtonsClass, this.PagingButtonsStyle, writer);
|
|
}
|
|
this.AddPagingButtonLayoutTag(writer);
|
|
}
|
|
if (this.NumericButtonType == PagingButtonType.Image)
|
|
{
|
|
this.writeSpacingStyle(writer);
|
|
if (!flag)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
writer.AddAttribute("href", this.GetHrefString(index), false);
|
|
}
|
|
this.AddClassAndStyle(this.PagingButtonsClass, this.PagingButtonsStyle, writer);
|
|
this.AddToolTip(writer, index);
|
|
this.AddHyperlinkTarget(writer);
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
this.CreateNumericImages(writer, index, false);
|
|
writer.RenderEndTag();
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(this.CurrentPageButtonClass))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CurrentPageButtonClass);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.CurrentPageButtonStyle))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Style, this.CurrentPageButtonStyle);
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
this.CreateNumericImages(writer, index, true);
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
else if (this.NumericButtonType == PagingButtonType.Button)
|
|
{
|
|
this.writeSpacingStyle(writer);
|
|
if (!flag)
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
writer.AddAttribute("href", this.GetHrefString(index), false);
|
|
}
|
|
this.AddClassAndStyle(this.PagingButtonsClass, this.PagingButtonsStyle, writer);
|
|
this.AddToolTip(writer, index);
|
|
this.AddHyperlinkTarget(writer);
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Button);
|
|
this.CreateNumericImages(writer, index, false);
|
|
writer.RenderEndTag();
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(this.CurrentPageButtonClass))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CurrentPageButtonClass);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.CurrentPageButtonStyle))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Style, this.CurrentPageButtonStyle);
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
this.CreateNumericImages(writer, index, true);
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
this.writeSpacingStyle(writer);
|
|
if (flag)
|
|
{
|
|
if (string.IsNullOrEmpty(this.CurrentPageButtonClass) && string.IsNullOrEmpty(this.CurrentPageButtonStyle))
|
|
{
|
|
writer.AddStyleAttribute(HtmlTextWriterStyle.FontWeight, "Bold");
|
|
writer.AddStyleAttribute(HtmlTextWriterStyle.Color, "red");
|
|
}
|
|
else
|
|
{
|
|
if (!string.IsNullOrEmpty(this.CurrentPageButtonClass))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CurrentPageButtonClass);
|
|
}
|
|
if (!string.IsNullOrEmpty(this.CurrentPageButtonStyle))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Style, this.CurrentPageButtonStyle);
|
|
}
|
|
}
|
|
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
if (!string.IsNullOrEmpty(this.CurrentPageButtonTextFormatString))
|
|
{
|
|
writer.Write(string.Format(this.CurrentPageButtonTextFormatString, index));
|
|
}
|
|
else
|
|
{
|
|
writer.Write(index);
|
|
}
|
|
writer.RenderEndTag();
|
|
}
|
|
else
|
|
{
|
|
if (this.Enabled)
|
|
{
|
|
writer.AddAttribute("href", this.GetHrefString(index), false);
|
|
this.AddClassAndStyle(this.PagingButtonsClass, this.PagingButtonsStyle, writer);
|
|
writer.AddAttribute("showwaiting", ""); //按下頁碼時顯示showwaiting遮罩 Modify By Ted 2014/09/24
|
|
}
|
|
this.AddToolTip(writer, index);
|
|
this.AddHyperlinkTarget(writer);
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
|
|
if (!string.IsNullOrEmpty(this.NumericButtonTextFormatString))
|
|
{
|
|
writer.Write(string.Format(this.NumericButtonTextFormatString, index));
|
|
}
|
|
else
|
|
{
|
|
writer.Write(index);
|
|
}
|
|
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
if ((!flag && (this.PagingButtonLayoutType != PagingButtonLayoutType.None)) || (flag && (this.PagingButtonLayoutType == PagingButtonLayoutType.UnorderedList)))
|
|
{
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
|
|
private void listPageIndices(HtmlTextWriter writer, int startIndex, int endIndex)
|
|
{
|
|
for (int i = startIndex; i <= endIndex; i++)
|
|
{
|
|
writer.Write("<option value=\"");
|
|
writer.Write(i);
|
|
writer.Write("\"");
|
|
if (i == this.CurrentPageIndex)
|
|
{
|
|
writer.Write(" selected=\"true\"");
|
|
}
|
|
writer.Write(">");
|
|
writer.Write(i);
|
|
writer.Write("</option>");
|
|
}
|
|
}
|
|
private static void addMoreListItem(HtmlTextWriter writer, int pageIndex)
|
|
{
|
|
writer.Write("<option value=\"");
|
|
writer.Write(pageIndex);
|
|
writer.Write("\">......</option>");
|
|
}
|
|
|
|
private void writeSpacingStyle(HtmlTextWriter writer)
|
|
{
|
|
if (this.PagingButtonSpacing.Value != 0.0)
|
|
{
|
|
writer.AddStyleAttribute(HtmlTextWriterStyle.MarginRight, this.PagingButtonSpacing.ToString());
|
|
}
|
|
}
|
|
|
|
private void CreateNavigationButton(HtmlTextWriter writer, NavigationButton btn)
|
|
{
|
|
if ((this.ShowFirstLast || ((btn != NavigationButton.First) && (btn != NavigationButton.Last))) && (this.ShowPrevNext || ((btn != NavigationButton.Prev) && (btn != NavigationButton.Next))))
|
|
{
|
|
//顯示第一頁和最後一頁,
|
|
string str;
|
|
bool flag;
|
|
int num;
|
|
if (this.PagingButtonLayoutType != PagingButtonLayoutType.None)
|
|
{
|
|
if (btn == NavigationButton.First)
|
|
{
|
|
this.AddClassAndStyle(this.FirstButtonsClass, this.FirstButtonsStyle, writer);
|
|
}
|
|
else if (btn == NavigationButton.Last)
|
|
{
|
|
this.AddClassAndStyle(this.LastButtonsClass, this.LastButtonsStyle, writer);
|
|
}
|
|
else if (btn == NavigationButton.Prev)
|
|
{
|
|
this.AddClassAndStyle(this.PrevButtonsClass, this.PrevButtonsStyle, writer);
|
|
}
|
|
else
|
|
{
|
|
this.AddClassAndStyle(this.NextButtonsClass, this.NextButtonsStyle, writer);
|
|
}
|
|
}
|
|
this.AddPagingButtonLayoutTag(writer);
|
|
string str2 = btn.ToString().ToLower();
|
|
//bool flag2 = this.NavigationButtonType == PagingButtonType.Image;
|
|
if ((btn == NavigationButton.First) || (btn == NavigationButton.Prev))
|
|
{
|
|
flag = (this.CurrentPageIndex <= 1) | !this.Enabled;
|
|
if (!this.ShowDisabledButtons && flag)
|
|
{
|
|
return;
|
|
}
|
|
num = (btn == NavigationButton.First) ? 1 : (this.CurrentPageIndex - 1);
|
|
this.writeSpacingStyle(writer);
|
|
if (this.PagingButtonLayoutType == PagingButtonLayoutType.None)
|
|
{
|
|
if (btn == NavigationButton.First)
|
|
{
|
|
this.AddClassAndStyle(this.FirstButtonsClass, this.FirstButtonsStyle, writer);
|
|
}
|
|
else if (btn == NavigationButton.Last)
|
|
{
|
|
this.AddClassAndStyle(this.LastButtonsClass, this.LastButtonsStyle, writer);
|
|
}
|
|
else if (btn == NavigationButton.Prev)
|
|
{
|
|
this.AddClassAndStyle(this.PrevButtonsClass, this.PrevButtonsStyle, writer);
|
|
}
|
|
else
|
|
{
|
|
this.AddClassAndStyle(this.NextButtonsClass, this.NextButtonsStyle, writer);
|
|
}
|
|
}
|
|
if (this.NavigationButtonType == PagingButtonType.Image)
|
|
{
|
|
if (!flag)
|
|
{
|
|
writer.AddAttribute("href", this.GetHrefString(num), false);
|
|
this.AddToolTip(writer, num);
|
|
this.AddHyperlinkTarget(writer);
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + str2 + this.ButtonImageNameExtension + this.ButtonImageExtension);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Img);
|
|
writer.RenderEndTag();
|
|
writer.RenderEndTag();
|
|
}
|
|
else
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + str2 + this.DisabledButtonImageNameExtension + this.ButtonImageExtension);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Img);
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
else if (this.NavigationButtonType == PagingButtonType.Button)
|
|
{
|
|
if (!flag)
|
|
{
|
|
//writer.AddAttribute("href", this.GetHrefString(num), false);
|
|
//this.AddToolTip(writer, num);
|
|
//this.AddHyperlinkTarget(writer);
|
|
//writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + str2 + this.ButtonImageNameExtension + this.ButtonImageExtension);
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Type, "button");
|
|
writer.AddAttribute("onclick", this.GetHrefString(num), false);
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
writer.AddAttribute("showwaiting", "");
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Input); //Modify By Ted 2014/07/30 改用button樣式產生
|
|
writer.RenderEndTag();
|
|
//writer.RenderEndTag();
|
|
}
|
|
else
|
|
{
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + str2 + this.DisabledButtonImageNameExtension + this.ButtonImageExtension);
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Type, "button");
|
|
writer.AddAttribute("onclick", "", false);
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
// writer.AddAttribute("showwaiting", "");del by Alina 20141105 當onclick為空時,不需要在有等待的效果
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Button); //Modify By Ted 2014/07/30 改用button樣式產生
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
str = (btn == NavigationButton.Prev) ? this.PrevPageText : this.FirstPageText;
|
|
if (flag)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
|
|
}
|
|
else
|
|
{
|
|
this.AddToolTip(writer, num);
|
|
this.AddHyperlinkTarget(writer);
|
|
writer.AddAttribute("href", this.GetHrefString(num), false);
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
writer.Write(str);
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
flag = (this.CurrentPageIndex >= this.PageCount) | !this.Enabled;
|
|
if (!this.ShowDisabledButtons && flag)
|
|
{
|
|
return;
|
|
}
|
|
num = (btn == NavigationButton.Last) ? this.PageCount : (this.CurrentPageIndex + 1);
|
|
this.writeSpacingStyle(writer);
|
|
if (this.PagingButtonLayoutType == PagingButtonLayoutType.None)
|
|
{
|
|
if (btn == NavigationButton.First)
|
|
{
|
|
this.AddClassAndStyle(this.FirstButtonsClass, this.FirstButtonsStyle, writer);
|
|
}
|
|
else if (btn == NavigationButton.Last)
|
|
{
|
|
this.AddClassAndStyle(this.LastButtonsClass, this.LastButtonsStyle, writer);
|
|
}
|
|
else if (btn == NavigationButton.Prev)
|
|
{
|
|
this.AddClassAndStyle(this.PrevButtonsClass, this.PrevButtonsStyle, writer);
|
|
}
|
|
else
|
|
{
|
|
this.AddClassAndStyle(this.NextButtonsClass, this.NextButtonsStyle, writer);
|
|
}
|
|
}
|
|
if (this.NavigationButtonType == PagingButtonType.Image)
|
|
{
|
|
if (!flag)
|
|
{
|
|
writer.AddAttribute("href", this.GetHrefString(num), false);
|
|
this.AddToolTip(writer, num);
|
|
this.AddHyperlinkTarget(writer);
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + str2 + this.ButtonImageNameExtension + this.ButtonImageExtension);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Input);
|
|
writer.RenderEndTag();
|
|
//writer.RenderEndTag();
|
|
}
|
|
else
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + str2 + this.DisabledButtonImageNameExtension + this.ButtonImageExtension);
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Img);
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
else if (this.NavigationButtonType == PagingButtonType.Button)
|
|
{
|
|
if (!flag)
|
|
{
|
|
//writer.AddAttribute("href", this.GetHrefString(num), false);
|
|
//this.AddToolTip(writer, num);
|
|
//this.AddHyperlinkTarget(writer);
|
|
//writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + str2 + this.ButtonImageNameExtension + this.ButtonImageExtension);
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
writer.AddAttribute("showwaiting", "");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Type, "button"); //Modify By Ted 2014/07/30 改用button樣式產生
|
|
writer.AddAttribute("onclick", this.GetHrefString(num), false);
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Input);
|
|
writer.RenderEndTag();
|
|
//writer.RenderEndTag();
|
|
}
|
|
else
|
|
{
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Src, this.ImagePath + str2 + this.DisabledButtonImageNameExtension + this.ButtonImageExtension);
|
|
//writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Type, "button");
|
|
writer.AddAttribute("onclick", "", false);
|
|
if (this.ButtonImageAlign != ImageAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
|
|
}
|
|
// writer.AddAttribute("showwaiting", "");del by Alina 20141105 當onclick為空時,不需要在有等待的效果
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Input); //Modify By Ted 2014/07/30 改用button樣式產生
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
str = (btn == NavigationButton.Next) ? this.NextPageText : this.LastPageText;
|
|
if (flag)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
|
|
}
|
|
else
|
|
{
|
|
this.AddToolTip(writer, num);
|
|
writer.AddAttribute("href", this.GetHrefString(num), false);
|
|
this.AddHyperlinkTarget(writer);
|
|
}
|
|
writer.RenderBeginTag(HtmlTextWriterTag.A);
|
|
writer.Write(str);
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
if (this.PagingButtonLayoutType != PagingButtonLayoutType.None)
|
|
{
|
|
writer.RenderEndTag();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void RenderNavigationSection(HtmlTextWriter writer)
|
|
{
|
|
if (this.CustomInfoSectionWidth.Type == UnitType.Percentage)
|
|
{
|
|
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, Unit.Percentage(100.0 - this.CustomInfoSectionWidth.Value).ToString());
|
|
}
|
|
if (this.HorizontalAlign != HorizontalAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.HorizontalAlign.ToString().ToLower());
|
|
}
|
|
if (!string.IsNullOrEmpty(this.CssClass))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CssClass);
|
|
}
|
|
if (this.LayoutType == LayoutType.Div)
|
|
{
|
|
writer.AddStyleAttribute("float", "left");
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Div);
|
|
}
|
|
else
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Valign, "bottom");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "true");
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
|
}
|
|
this.RenderPagingElements(writer);
|
|
writer.RenderEndTag();
|
|
}
|
|
private void RenderCustomInfoSection(HtmlTextWriter writer)
|
|
{
|
|
if (this.Height != Unit.Empty)
|
|
{
|
|
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.Height.ToString());
|
|
}
|
|
string str = this.CustomInfoSectionWidth.ToString();
|
|
if ((this.CustomInfoClass != null) && (this.CustomInfoClass.Trim().Length > 0))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CustomInfoClass);
|
|
}
|
|
if ((this.CustomInfoStyle != null) && (this.CustomInfoStyle.Trim().Length > 0))
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Style, this.CustomInfoStyle);
|
|
}
|
|
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, str);
|
|
if (this.CustomInfoTextAlign != HorizontalAlign.NotSet)
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.CustomInfoTextAlign.ToString().ToLower());
|
|
}
|
|
if (this.LayoutType == LayoutType.Div)
|
|
{
|
|
writer.AddStyleAttribute("float", "left");
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Div);
|
|
}
|
|
else
|
|
{
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Valign, "bottom");
|
|
writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "true");
|
|
writer.RenderBeginTag(HtmlTextWriterTag.Td);
|
|
}
|
|
writer.Write(this.GetCustomInfoHtml(this.CustomInfoHTML));
|
|
writer.RenderEndTag();
|
|
}
|
|
|
|
private string GetCustomInfoHtml(string origText)
|
|
{
|
|
if (string.IsNullOrEmpty(origText) || (origText.IndexOf('%') < 0))
|
|
{
|
|
return origText;
|
|
}
|
|
string[] array = new string[] { "recordcount", "pagecount", "currentpageindex", "startrecordindex", "endrecordindex", "pagesize", "pagesremain", "recordsremain" };
|
|
StringBuilder builder = new StringBuilder(origText);
|
|
Regex regex = new Regex(@"(?<ph>%(?<pname>\w{8,})%)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
|
foreach (Match match in regex.Matches(origText))
|
|
{
|
|
string str = match.Groups["pname"].Value.ToLower();
|
|
if (Array.IndexOf<string>(array, str) >= 0)
|
|
{
|
|
string newValue = null;
|
|
switch (str)
|
|
{
|
|
case "recordcount":
|
|
newValue = this.RecordCount.ToString();
|
|
break;
|
|
|
|
case "pagecount":
|
|
newValue = this.PageCount.ToString();
|
|
break;
|
|
|
|
case "currentpageindex":
|
|
newValue = this.CurrentPageIndex.ToString();
|
|
break;
|
|
|
|
case "startrecordindex":
|
|
newValue = this.StartRecordIndex.ToString();
|
|
break;
|
|
|
|
case "endrecordindex":
|
|
newValue = this.EndRecordIndex.ToString();
|
|
break;
|
|
|
|
case "pagesize":
|
|
newValue = this.PageSize.ToString();
|
|
break;
|
|
|
|
case "pagesremain":
|
|
newValue = this.PagesRemain.ToString();
|
|
break;
|
|
|
|
case "recordsremain":
|
|
newValue = this.RecordsRemain.ToString();
|
|
break;
|
|
}
|
|
if (newValue != null)
|
|
{
|
|
builder.Replace(match.Groups["ph"].Value, newValue);
|
|
}
|
|
}
|
|
}
|
|
return builder.ToString();
|
|
}
|
|
|
|
private string GetHrefString(int pageIndex)
|
|
{
|
|
if (!this.UrlPaging)
|
|
{
|
|
return this.Page.ClientScript.GetPostBackClientHyperlink(this, pageIndex.ToString());
|
|
}
|
|
int num = pageIndex;
|
|
string str = "pi";
|
|
if (this.ReverseUrlPageIndex)
|
|
{
|
|
str = "(" + this.PageCount + "-pi+1)";
|
|
num = (pageIndex == -1) ? -1 : ((this.PageCount - pageIndex) + 1);
|
|
}
|
|
if (!this.EnableUrlRewriting)
|
|
{
|
|
return this.BuildUrlString(this.UrlPageIndexName, (num == -1) ? ("\"+" + str + "+\"") : num.ToString());
|
|
}
|
|
MatchCollection matchs = new Regex("(?<p>%(?<m>[^%]+)%)", RegexOptions.Compiled | RegexOptions.IgnoreCase).Matches(this.UrlRewritePattern);
|
|
NameValueCollection values = ConvertQueryStringToCollection(this.queryString);
|
|
string urlRewritePattern = this.UrlRewritePattern;
|
|
foreach (Match match in matchs)
|
|
{
|
|
string newValue = values[match.Groups["m"].Value];
|
|
urlRewritePattern = urlRewritePattern.Replace(match.Groups["p"].Value, newValue);
|
|
}
|
|
return base.ResolveUrl(string.Format(urlRewritePattern, (num == -1) ? ("\"+" + str + "+\"") : num.ToString()));
|
|
}
|
|
|
|
private string BuildUrlString(string sk, string sv)
|
|
{
|
|
StringBuilder builder = new StringBuilder(80);
|
|
bool flag = false;
|
|
int num = (this.queryString != null) ? this.queryString.Length : 0;
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
string str2;
|
|
int startIndex = i;
|
|
int num4 = -1;
|
|
while (i < num)
|
|
{
|
|
char ch = this.queryString[i];
|
|
if (ch == '=')
|
|
{
|
|
if (num4 < 0)
|
|
{
|
|
num4 = i;
|
|
}
|
|
}
|
|
else if (ch == '&')
|
|
{
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
string str = null;
|
|
if (num4 >= 0)
|
|
{
|
|
str = this.queryString.Substring(startIndex, num4 - startIndex);
|
|
str2 = this.queryString.Substring(num4 + 1, (i - num4) - 1);
|
|
}
|
|
else
|
|
{
|
|
str2 = this.queryString.Substring(startIndex, i - startIndex);
|
|
}
|
|
builder.Append(str).Append("=");
|
|
if (str == sk)
|
|
{
|
|
flag = true;
|
|
builder.Append(sv);
|
|
}
|
|
else
|
|
{
|
|
builder.Append(str2);
|
|
}
|
|
builder.Append("&");
|
|
}
|
|
if (!flag)
|
|
{
|
|
builder.Append(sk).Append("=").Append(sv);
|
|
}
|
|
builder.Insert(0, "?").Insert(0, Path.GetFileName(this.currentUrl));
|
|
return builder.ToString().Trim(new char[] { '&' });
|
|
}
|
|
|
|
private static NameValueCollection ConvertQueryStringToCollection(string s)
|
|
{
|
|
NameValueCollection values = new NameValueCollection();
|
|
int num = (s != null) ? s.Length : 0;
|
|
for (int i = 0; i < num; i++)
|
|
{
|
|
string str2;
|
|
int startIndex = i;
|
|
int num4 = -1;
|
|
while (i < num)
|
|
{
|
|
char ch = s[i];
|
|
if (ch == '=')
|
|
{
|
|
if (num4 < 0)
|
|
{
|
|
num4 = i;
|
|
}
|
|
}
|
|
else if (ch == '&')
|
|
{
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
string name = null;
|
|
if (num4 >= 0)
|
|
{
|
|
name = s.Substring(startIndex, num4 - startIndex);
|
|
str2 = s.Substring(num4 + 1, (i - num4) - 1);
|
|
}
|
|
else
|
|
{
|
|
str2 = s.Substring(startIndex, i - startIndex);
|
|
}
|
|
values.Add(name, str2);
|
|
if ((i == (num - 1)) && (s[i] == '&'))
|
|
{
|
|
values.Add(null, string.Empty);
|
|
}
|
|
}
|
|
return values;
|
|
}
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region PageChangingEventHandler Delegate
|
|
public delegate void PageChangingEventHandler(object src, PageChangingEventArgs e);
|
|
|
|
#endregion
|
|
|
|
}
|