AspNetPager6.0分页控件 增强版

    技术2022-05-11  95

     增加了可自定义每页的记录数,并修订了在ajax的情况下,js不能动态绑定页面记录数绑定的问题

    部分代码如下:

     

            /// <include file='AspNetPagerDocs.xml' path='AspNetPagerDoc/Method[@name="RenderContents"]/*'/>          protected   override   void  RenderContents(HtmlTextWriter writer)         {            if (PageCount <= 1 && !AlwaysShow)                return;            if (ShowCustomInfoSection == ShowCustomInfoSection.Left)            {                writer.Write(GetCustomInfoText(CustomInfoHTML));                writer.RenderEndTag();                WriteCellAttributes(writer, false);                writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClass);                writer.RenderBeginTag(HtmlTextWriterTag.Td);            }            int midpage = ((CurrentPageIndex - 1/ NumericButtonCount);            int pageoffset = midpage * NumericButtonCount;            int endpage = ((pageoffset + NumericButtonCount) > PageCount) ? PageCount : (pageoffset + NumericButtonCount);            this.CreateNavigationButton(writer, "first");            this.CreateNavigationButton(writer, "prev");            if (ShowPageIndex)            {                if (CurrentPageIndex > NumericButtonCount)                    CreateMoreButton(writer, pageoffset);                for (int i = pageoffset + 1; i <= endpage; i++)                {                    CreateNumericButton(writer, i);                }                if (PageCount > NumericButtonCount && endpage < PageCount)                    CreateMoreButton(writer, endpage + 1);            }            this.CreateNavigationButton(writer, "next");            this.CreateNavigationButton(writer, "last");            if ((ShowInputBox == ShowInputBox.Always) || (ShowInputBox == ShowInputBox.Auto && PageCount >= ShowBoxThreshold))            {                string inputClientID = this.UniqueID + "_input";                writer.Write("  ");                if (!string.IsNullOrEmpty(TextBeforeInputBox))                    writer.Write(TextBeforeInputBox);                writer.AddAttribute(HtmlTextWriterAttribute.Type, "text");                writer.AddStyleAttribute(HtmlTextWriterStyle.Width, "30px");                writer.AddAttribute(HtmlTextWriterAttribute.Value, CurrentPageIndex.ToString());                if (!string.IsNullOrEmpty(InputBoxStyle))                    writer.AddAttribute(HtmlTextWriterAttribute.Style, InputBoxStyle);                if (!string.IsNullOrEmpty(InputBoxClass))                    writer.AddAttribute(HtmlTextWriterAttribute.Class, InputBoxClass);                if (PageCount <= 1 && AlwaysShow)                    writer.AddAttribute(HtmlTextWriterAttribute.ReadOnly, "true");                writer.AddAttribute(HtmlTextWriterAttribute.Name, inputClientID);                writer.AddAttribute(HtmlTextWriterAttribute.Id, inputClientID);                string chkInputScript = "ANP_checkInput('" + inputClientID + "'," + PageCount.ToString() + ")";                string keydownScript = "ANP_keydown(event,'" + this.UniqueID + "_btn');";                string clickScript = "if(" + chkInputScript + "){ANP_goToPage(document.getElementById('" + inputClientID + "'));}";                writer.AddAttribute("onkeydown", keydownScript);                writer.RenderBeginTag(HtmlTextWriterTag.Input);                writer.RenderEndTag();                if (!string.IsNullOrEmpty(TextAfterInputBox))                    writer.Write(TextAfterInputBox);                writer.AddAttribute(HtmlTextWriterAttribute.Type, (UrlPaging == true? "Button" : "Submit");                writer.AddAttribute(HtmlTextWriterAttribute.Name, this.UniqueID);                writer.AddAttribute(HtmlTextWriterAttribute.Id, this.UniqueID + "_btn");                writer.AddAttribute(HtmlTextWriterAttribute.Value, SubmitButtonText);                if (!string.IsNullOrEmpty(SubmitButtonClass))                    writer.AddAttribute(HtmlTextWriterAttribute.Class, SubmitButtonClass);                if (!string.IsNullOrEmpty(SubmitButtonStyle))                    writer.AddAttribute(HtmlTextWriterAttribute.Style, SubmitButtonStyle);                //TODO:chen gang 2007-01-25 增加鼠标移动样式改变                if (SubmitButtonOnMouseOver != null && SubmitButtonOnMouseOver.Trim().Length > 0)                    writer.AddAttribute("onmouseover""this.className='" + SubmitButtonOnMouseOver + "';");                if (SubmitButtonOnMouseOut != null && SubmitButtonOnMouseOut.Trim().Length > 0)                    writer.AddAttribute("onmouseout""this.className='" + SubmitButtonOnMouseOut + "';");                if (PageCount <= 1 && AlwaysShow)                    writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "true");                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, (UrlPaging == true? clickScript : "return " + chkInputScript);                writer.RenderBeginTag(HtmlTextWriterTag.Input);                writer.RenderEndTag();            }            add by chengang add by chengang            if (ShowCustomInfoSection == ShowCustomInfoSection.Right)            {                writer.RenderEndTag();                WriteCellAttributes(writer, false);                writer.RenderBeginTag(HtmlTextWriterTag.Td);                writer.Write(GetCustomInfoText(CustomInfoHTML));            }        }          #endregion

    如需要全部代码联系我msn:eme915@hotmail.com


    最新回复(0)