📄 aspnetpager.cs
字号:
}
else
{
writer.Write(this.ChinesePageIndex ? GetChinesePageIndex(index) : index.ToString());
}
writer.RenderEndTag();
}
this.WriteButtonSpace(writer);
}
private void CreateNumericImages(HtmlTextWriter writer, int index, bool isCurrent)
{
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 }));
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.ButtonImageAlign.ToString());
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
writer.RenderBeginTag(HtmlTextWriterTag.Img);
writer.RenderEndTag();
}
}
private void CreatePageSize(HtmlTextWriter writer)
{
if (this.ShowPageSize)
{
writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID + "_inputPageSize");
writer.AddAttribute(HtmlTextWriterAttribute.Id, this.UniqueID + "_inputPageSize");
writer.AddAttribute(HtmlTextWriterAttribute.Value, this.PageSize.ToString());
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, "12px");
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "20px");
this.Page.ClientScript.GetPostBackClientHyperlink(this, "");
string str = "if(doCheckPageSize(document.getElementById('" + this.UniqueID + "_inputPageSize')))__doPostBack('" + this.UniqueID + "','');else{event.returnValue=false;}";
writer.AddAttribute("onchange", str);
writer.RenderBeginTag(HtmlTextWriterTag.Input);
writer.RenderEndTag();
writer.Write("个/页");
writer.Write(" ");
}
}
private static string GetChinesePageIndex(int index)
{
Hashtable hashtable = new Hashtable();
hashtable.Add("0", "零");
hashtable.Add("1", "一");
hashtable.Add("2", "二");
hashtable.Add("3", "三");
hashtable.Add("4", "四");
hashtable.Add("5", "五");
hashtable.Add("6", "六");
hashtable.Add("7", "七");
hashtable.Add("8", "八");
hashtable.Add("9", "九");
string str = index.ToString();
StringBuilder builder = new StringBuilder();
for (int i = 0; i < str.Length; i++)
{
char ch = str[i];
builder.Append(hashtable[ch.ToString()]);
}
return builder.ToString();
}
private string GetHrefString(int pageIndex)
{
if (this.urlPaging)
{
NameValueCollection col = new NameValueCollection();
col.Add(this.urlPageIndexName, pageIndex.ToString());
return this.BuildUrlString(col);
}
return this.Page.ClientScript.GetPostBackClientHyperlink(this, pageIndex.ToString());
}
private string GetStyleString()
{
if (base.Style.Count <= 0)
{
return null;
}
string[] array = new string[base.Style.Count];
base.Style.Keys.CopyTo(array, 0);
StringBuilder builder = new StringBuilder();
for (int i = 0; i < array.Length; i++)
{
builder.Append(array[i] + ":" + base.Style[array[i]] + ";");
}
return builder.ToString();
}
public virtual bool LoadPostData(string postDataKey, NameValueCollection postCollection)
{
string s = postCollection[this.UniqueID + "_input"];
if ((s != null) && (s.Trim().Length > 0))
{
try
{
if (int.Parse(s) > 0)
{
this.inputPageIndex = s;
this.Page.RegisterRequiresRaiseEvent(this);
}
}
catch
{
}
}
this.Page.RegisterRequiresRaiseEvent(this);
return false;
}
protected override void OnLoad(EventArgs e)
{
if (this.urlPaging)
{
this.currentUrl = this.Page.Request.Path;
this.urlParams = this.Page.Request.QueryString;
string s = this.Page.Request.QueryString[this.urlPageIndexName];
int newPageIndex = 1;
try
{
newPageIndex = int.Parse(s);
}
catch
{
}
this.inputPageSize = this.Page.Request.Form[this.UniqueID + "_inputPageSize"];
if (!string.IsNullOrEmpty(this.Page.Request.Form[this.UniqueID + "_inputPageSize"]))
{
this.PageSize = int.Parse(this.Page.Request.Form[this.UniqueID + "_inputPageSize"]);
}
this.OnPageChanged(new PageChangedEventArgs(newPageIndex));
}
else
{
this.inputPageIndex = this.Page.Request.Form[this.UniqueID + "_input"];
this.inputPageSize = this.Page.Request.Form[this.UniqueID + "_inputPageSize"];
}
base.OnLoad(e);
}
protected virtual void OnPageChanged(PageChangedEventArgs e)
{
if (this.PageChanged != null)
{
this.PageChanged(this, e);
}
}
protected override void OnPreRender(EventArgs e)
{
if (this.PageCount >= 1)
{
string script = "<script language=\"Javascript\">function doCheck(el){var r=new RegExp(\"^\\\\s*(\\\\d+)\\\\s*$\");if(r.test(el.value)){if(RegExp.$1<1||RegExp.$1>" + this.PageCount.ToString() + "){alert(\"" + this.PageIndexOutOfRangeErrorString + "\");return false;}return true;}alert(\"" + this.InvalidPageIndexErrorString + "\");return false;}function doCheckPageSize(el){var r=new RegExp(\"^\\\\s*(\\\\d+)\\\\s*$\");if(r.test(el.value)){if(RegExp.$1<1||RegExp.$1>500){alert(\"一页显示记录数不得超过500\");return false;}return true;}alert(\"请输入正确的字符\");return false;}</script>";
if ((this.ShowInputBox == PowerEasy.Controls.ShowInputBox.Always) || ((this.ShowInputBox == PowerEasy.Controls.ShowInputBox.Auto) && (this.PageCount >= this.ShowBoxThreshold)))
{
if (!this.Page.ClientScript.IsClientScriptBlockRegistered("AspNetPager_checkinput"))
{
this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "AspNetPager_checkinput", script);
}
string str2 = "<script language=\"javascript\" > <!-- \nfunction BuildUrlString(key,value){ var _key=key.toLowerCase(); var prms=location.search; if(prms.length==0) return location.pathname+\"?\"+_key+\"=\"+value; var params=prms.substring(1).split(\"&\"); var newparam=\"\"; var found=false; for(i=0;i<params.length;i++){ if(params[i].split(\"=\")[0].toLowerCase()==_key){ params[i]=_key+\"=\"+value; found=true; break; } } if(found) return location.pathname+\"?\"+params.join(\"&\"); else return location+\"&\"+_key+\"=\"+value; }\n//--> </script>";
if (!this.Page.ClientScript.IsClientScriptBlockRegistered("AspNetPager_BuildUrlScript"))
{
this.Page.ClientScript.RegisterClientScriptBlock(base.GetType(), "AspNetPager_BuildUrlScript", str2);
}
}
}
base.OnPreRender(e);
}
public void RaisePostBackEvent(string eventArgument)
{
int currentPageIndex = this.CurrentPageIndex;
try
{
if (!string.IsNullOrEmpty(this.inputPageSize) && (this.PageSize != int.Parse(this.inputPageSize)))
{
this.PageSize = int.Parse(this.inputPageSize);
this.CurrentPageIndex = 1;
currentPageIndex = 1;
}
if (string.IsNullOrEmpty(eventArgument))
{
eventArgument = this.inputPageIndex;
}
currentPageIndex = int.Parse(eventArgument);
}
catch
{
}
this.OnPageChanged(new PageChangedEventArgs(currentPageIndex));
}
public virtual void RaisePostDataChangedEvent()
{
}
public override void RenderBeginTag(HtmlTextWriter writer)
{
bool flag = (this.PageCount > 1) || ((this.PageCount <= 1) && this.AlwaysShow);
writer.WriteLine();
base.RenderBeginTag(writer);
if (((this.ShowCustomInfoSection == PowerEasy.Controls.ShowCustomInfoSection.Left) || (this.ShowCustomInfoSection == PowerEasy.Controls.ShowCustomInfoSection.Right)) && flag)
{
writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
writer.AddAttribute(HtmlTextWriterAttribute.Style, this.GetStyleString());
if (this.Height != Unit.Empty)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Height, this.Height.ToString());
}
writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.AddAttribute(HtmlTextWriterAttribute.Align, "center");
writer.RenderBeginTag(HtmlTextWriterTag.Td);
}
}
protected override void RenderContents(HtmlTextWriter writer)
{
if ((this.PageCount >= 0) || this.AlwaysShow)
{
if (this.ShowCustomInfoSection == PowerEasy.Controls.ShowCustomInfoSection.Left)
{
writer.Write(this.CustomInfoText);
writer.RenderEndTag();
this.WriteCellAttributes(writer, false);
writer.AddAttribute(HtmlTextWriterAttribute.Class, this.CssClass);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
}
int num = (this.CurrentPageIndex - 1) / this.NumericButtonCount;
int pageIndex = num * this.NumericButtonCount;
int num3 = ((pageIndex + this.NumericButtonCount) > this.PageCount) ? this.PageCount : (pageIndex + this.NumericButtonCount);
writer.Write("总共<font color='green'>" + this.RecordCount.ToString() + "</font>条记录");
writer.Write(" ");
this.CreateNavigationButton(writer, "first");
writer.Write(" ");
this.CreateNavigationButton(writer, "prev");
writer.Write(" ");
if (this.ShowPageIndex)
{
if (this.CurrentPageIndex > this.NumericButtonCount)
{
this.CreateMoreButton(writer, pageIndex);
}
for (int i = pageIndex + 1; i <= num3; i++)
{
this.CreateNumericButton(writer, i);
}
if ((this.PageCount > this.NumericButtonCount) && (num3 < this.PageCount))
{
this.CreateMoreButton(writer, num3 + 1);
}
}
this.CreateNavigationButton(writer, "next");
writer.Write(" ");
this.CreateNavigationButton(writer, "last");
writer.Write(" ");
this.CreatePageSize(writer);
writer.Write(string.Concat(new object[] { "页次:<font color='red'>", this.CurrentPageIndex.ToString(), "</font>/", this.PageCount, "页" }));
this.CreateInputBox(writer);
if (this.ShowCustomInfoSection == PowerEasy.Controls.ShowCustomInfoSection.Right)
{
writer.RenderEndTag();
this.WriteCellAttributes(writer, false);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write(this.CustomInfoText);
}
}
}
public override void RenderEndTag(HtmlTextWriter writer)
{
if (((this.ShowCustomInfoSection == PowerEasy.Controls.ShowCustomInfoSection.Left) || (this.ShowCustomInfoSection == PowerEasy.Controls.ShowCustomInfoSection.Right)) && ((this.PageCount > 1) || ((this.PageCount <= 1) && this.AlwaysShow)))
{
writer.RenderEndTag();
writer.RenderEndTag();
writer.RenderEndTag();
}
base.RenderEndTag(writer);
writer.WriteLine();
}
private void WriteButtonSpace(HtmlTextWriter writer)
{
if (this.PagingButtonSpacing.Value > 0.0)
{
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, this.PagingButtonSpacing.ToString());
writer.RenderBeginTag(HtmlTextWriterTag.Span);
writer.RenderEndTag();
}
}
private void WriteCellAttributes(HtmlTextWriter writer, bool leftCell)
{
string str = this.CustomInfoSectionWidth.ToString();
if (((this.ShowCustomInfoSection == PowerEasy.Controls.ShowCustomInfoSection.Left) && leftCell) || ((this.ShowCustomInfoSection == PowerEasy.Controls.ShowCustomInfoSection.Right) && !leftCell))
{
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.AddAttribute(HtmlTextWriterAttribute.Valign, "bottom");
writer.AddStyleAttribute(HtmlTextWriterStyle.Width, str);
writer.AddAttribute(HtmlTextWriterAttribute.Align, this.CustomInfoTextAlign.ToString().ToLower());
}
else
{
if (this.CustomInfoSectionWidth.Type == UnitType.Percentage)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -