Пример #1
0
        private string getLinkHtml(PagerType type)
        {
            string linkTemplate     = "<a href=\"{0}\" class=\"{1}\">{2}</a>";
            string pageInfoTemplate = RS.get("RepeaterEx_Pager_PageInfoTemplate");
            string link             = string.Empty;
            string @class           = string.Empty;
            string text             = string.Empty;

            switch (type)
            {
            case PagerType.FirstPage:
                link   = CurrentPageIndex <= 1 ? "javascript:;" : GetCurrentFullUrl + "1";
                @class = "firstPage";
                text   = ShowPagerText ? RS.get("RepeaterEx_Pager_FirstPageText") : "";
                break;

            case PagerType.PrePage:
                link   = CurrentPageIndex <= 1 ? "javascript:;" : GetCurrentFullUrl + (CurrentPageIndex - 1);
                @class = "prePage";
                text   = ShowPagerText ? RS.get("RepeaterEx_Pager_PrePageText") : "";
                break;

            case PagerType.NextPage:
                link   = CurrentPageIndex >= _maxPages ? "javascript:;" : GetCurrentFullUrl + (CurrentPageIndex + 1);
                @class = "nextPage";
                text   = ShowPagerText ? RS.get("RepeaterEx_Pager_NextPageText") : "";
                break;

            case PagerType.LastPage:
                link   = _maxPages == 0 ? "javascript:;" : (GetCurrentFullUrl + _maxPages);
                @class = "lastPage";
                text   = ShowPagerText ? RS.get("RepeaterEx_Pager_LastPageText") : "";
                break;

            case PagerType.PageInfo:
                return(string.Format(pageInfoTemplate + "&nbsp;&nbsp;", _maxRecord, _maxPages == 0 ? 0 : CurrentPageIndex, _maxPages));

            default:
                break;
            }

            return(string.Format(linkTemplate, link, @class, text));
        }
        private RepeaterXPagerLinkButton createButton(PagerType pagerType, int pageIndex)
        {
            RepeaterXPagerLinkButton btn = new RepeaterXPagerLinkButton(this);

            switch (pagerType)
            {
            case PagerType.First:
                btn.Text           = "首页";
                btn.Font.Underline = false;
                break;

            case PagerType.Previous:
                btn.Text           = "上一页";
                btn.Font.Underline = false;
                break;

            case PagerType.Next:
                btn.Text           = "下一页";
                btn.Font.Underline = false;
                break;

            case PagerType.Last:
                btn.Text           = "末页";
                btn.Font.Underline = false;
                break;

            case PagerType.Numeric:
                btn.Text = (pageIndex + 1).ToString();
                break;

            case PagerType.NumericPrevNext:
                btn.Text = "...";
                break;
            }
            btn.CommandName     = "navigate";
            btn.CommandArgument = pageIndex.ToString();

            return(btn);
        }
Пример #3
0
 //初始化控件时调用的系统方法
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     this.PART_Content      = this.GetTemplateChild(MISPager.MIS_PART_CONTENT) as StackPanel;
     this.PART_Nextpage     = this.GetTemplateChild(MISPager.MIS_PART_NEXTPAGE) as MISImageButton;
     this.PART_Previouspage = this.GetTemplateChild(MISPager.MIS_PART_PREVIOUSPAGE) as MISImageButton;
     this.PART_Count        = this.GetTemplateChild(MISPager.MIS_PART_COUNT) as TextBlock;
     this.PART_PageIndex    = this.GetTemplateChild(MISPager.MIS_PART_PAGEINDEX) as TextBlock;
     //计算页码数
     this.PageCount       = (Int32)Math.Ceiling((Double)this.Total / (Double)this.PageSize);
     this.PART_Count.Text = this.Total.ToString();
     //当总页码小于7页,显示1、2、3、4、5、6、7
     if (this.PageCount <= 7)
     {
         this.mPagerType = PagerType.Default;
         for (int i = 0; i < this.PageCount; i++)
         {
             var misImgBtn = new MISLinkButton()
             {
                 Content         = (i + 1).ToString(),
                 Width           = 35,
                 BorderThickness = new Thickness(1, 0, 0, 0),
                 Style           = Application.Current.FindResource("DefaultLinkButton2Style") as Style
             };
             this.mCurrentPagers.Add((i + 1));
             misImgBtn.Click += OnMisImgBtn_Click;
             if (this.PART_Content != null)
             {
                 this.PART_Content.Children.Add(misImgBtn);
             }
         }
     }
     else
     {
         this.mPagerType = PagerType.Complex;
         for (int i = 0; i < 5; i++)
         {
             var misImgBtn = new MISLinkButton()
             {
                 Content = (i + 1).ToString(), Width = 35, BorderThickness = new Thickness(1, 0, 0, 0), Style = Application.Current.FindResource("DefaultLinkButton2Style") as Style
             };
             misImgBtn.Click += OnMisImgBtn_Click;
             if (i.Equals(0))
             {
                 misImgBtn.Tag = 0;                                   //设置左控制点
             }
             if (i.Equals(4))
             {
                 misImgBtn.Tag = 5;                                   //设置右控制点
             }
             this.mCurrentPagers.Add((i + 1));
             if (this.PART_Content != null)
             {
                 this.PART_Content.Children.Add(misImgBtn);
             }
         }
         this.PART_Content.Children.Add(new MISLinkButton()
         {
             Content = "...", Width = 35, BorderThickness = new Thickness(1, 0, 0, 0), Style = Application.Current.FindResource("DefaultLinkButton3Style") as Style
         });
         this.PART_Content.Children.Add(new MISLinkButton()
         {
             Content = this.PageCount.ToString(), Width = 35, BorderThickness = new Thickness(1, 0, 0, 0), Style = Application.Current.FindResource("DefaultLinkButton2Style") as Style
         });
     }
     this.SetLinkButtonFocus(0);
     this._SetNextpageAndPreviouspageState();
     if (this.PART_Previouspage != null)
     {
         this.PART_Previouspage.Click += OnPART_Previouspage_Click;
     }
     if (this.PART_Nextpage != null)
     {
         this.PART_Nextpage.Click += OnPART_Nextpage_Click;
     }
 }
Пример #4
0
        /// <summary>
        /// 输出分页HTML标记
        /// <remarks>
        /// <para>方向链接分页·无地址[Ajax、MVC、静态URL]</para>
        /// <para>格式:首页 上一页 下一页 末页</para>
        /// <para>引用 DawnPagerUI.css 文件</para>
        /// <para>引用 DawnPagerJS.js 文件</para>
        /// </remarks>
        /// </summary>
        /// <param name="parameter">URL参数,分页模式的特定格式,详见JS文件</param>
        /// <param name="outPageCount">是否输出实时页总条数,需要给PageRecordCount实时赋值</param>
        /// <param name="showSelect">是否输出页码选择器</param>
        /// <param name="pagerType">数据分页模式</param>
        /// <param name="outPageGoto">是否输出分页跳转功能代码</param>
        /// <param name="outPageGotoFun">分页跳转功能函数名称</param>
        /// <returns>HTML</returns>
        public string ShowPagerByScriptByForwardOf(string parameter = null, bool outPageCount = true, bool showSelect = false, PagerType pagerType = PagerType.Mvc, bool outPageGoto = true, string outPageGotoFun = "DawnPagerGotoOf")
        {
            var tmpResult = this.BalefulToPager();

            if (!string.IsNullOrEmpty(tmpResult))
            {
                return(tmpResult);
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("<div id=\"pagerList\">");
            //分页数据信息
            if (outPageCount)
            {
                if (this.PageRecordCount > 0 && this.PageRecordCount < this.PageSize)
                {
                    sb.AppendFormat("共 {0} 条,每页 {1}/{2} 条,第 {3}/{4} 页 ", this.RecordCount, this.PageRecordCount, this.PageSize, this.PageCurrent, this.PageCount);
                }
                else
                {
                    sb.AppendFormat("共 {0} 条,每页 {1} 条,第 {2}/{3} 页 ", this.RecordCount, this.PageSize, this.PageCurrent, this.PageCount);
                }
            }
            else
            {
                sb.AppendFormat("共 {0} 条,每页 {1} 条,第 {2}/{3} 页 ", this.RecordCount, this.PageSize, this.PageCurrent, this.PageCount);
            }
            //判断并确认数据分页模式
            var jsFunName = "DawnPagerHandlerOf";

            switch (pagerType)
            {
            case PagerType.Ajax:
                jsFunName = "DawnPagerHandlerOf";
                break;

            case PagerType.Mvc:
                jsFunName = "DawnPagerMvcOf";
                break;

            case PagerType.Url:
                jsFunName = "DawnPagerUrlOf";
                break;
            }
            //首页
            if (this.PageCurrent == 1)
            {
                sb.Append("<span>首页</span>");
            }
            else
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}(1,'{1}');\">首页</a>", jsFunName, parameter);
            }
            //上一页
            if (this.PageCurrent <= 1)
            {
                sb.Append("&nbsp;&nbsp;<span>上一页</span>&nbsp;&nbsp;");
            }
            else
            {
                sb.AppendFormat("&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">上一页</a>&nbsp;&nbsp;", jsFunName, this.PageCurrent - 1, parameter);
            }
            //下一页
            if (this.PageCurrent >= this.PageCount)
            {
                sb.Append("<span>下一页</span>&nbsp;&nbsp;");
            }
            else
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">下一页</a>&nbsp;&nbsp;", jsFunName, this.PageCurrent + 1, parameter);
            }
            //末页
            if (this.PageCurrent == this.PageCount | this.PageCount == 0)
            {
                sb.Append("<span>末页</span>");
            }
            else
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">末页</a>", jsFunName, this.PageCount, parameter);
            }
            //页码选择器
            if (showSelect)
            {
                sb.AppendFormat("&nbsp;&nbsp;<select onchange=\"{0}(this.value,'{1}');\">", jsFunName, parameter);
                for (int i = 1; i <= this.PageCount; i++)
                {
                    if (i == this.PageCurrent)
                    {
                        sb.AppendFormat("<option value=\"{0}\" selected=\"selected\">{0}</option>", i);
                    }
                    else
                    {
                        sb.AppendFormat("<option value=\"{0}\">{0}</option>", i);
                    }
                }
                sb.Append("</select>");
            }
            //跳转功能
            if (outPageGoto)
            {
                sb.AppendFormat("<span class=\"gotoarea\"><input type=\"hidden\" id=\"hidPagerMax\" value=\"{0}\" /><input type=\"text\" id=\"txtPagerIndex\" value=\"{4}\" /><label onclick=\"{1}('{2}','{3}');\">跳转</label></span>", this.PageCount, outPageGotoFun, jsFunName, parameter, this.PageCurrent);
            }
            sb.Append("</div>");
            return(sb.ToString());
        }
Пример #5
0
        /// <summary>
        /// 输出分页HTML标记
        /// <remarks>
        /// <para>数字链接分页·无地址[Ajax、MVC、静态URL]</para>
        /// <para>默认每页9链接,必须为单数</para>
        /// <para>格式:上一页 1 2...10 下一页</para>
        /// <para>引用 DawnPagerUI.css 文件</para>
        /// <para>引用 DawnPagerJS.js 文件</para>
        /// </remarks>
        /// </summary>
        /// <param name="parameter">URL参数,分页模式的特定格式,详见JS文件</param>
        /// <param name="outPageCount">是否输出实时页总条数,需要给PageRecordCount实时赋值</param>
        /// <param name="pagerType">数据分页模式</param>
        /// <param name="outPageGoto">是否输出分页跳转功能代码</param>
        /// <param name="outPageGotoFun">分页跳转功能函数名称</param>
        /// <returns>HTML</returns>
        public string ShowPagerByScriptByNumericOf(string parameter = null, bool outPageCount = true, PagerType pagerType = PagerType.Mvc, bool outPageGoto = true, string outPageGotoFun = "DawnPagerGotoOf")
        {
            var tmpResult = this.BalefulToPager();

            if (!string.IsNullOrEmpty(tmpResult))
            {
                return(tmpResult);
            }
            //计算数字分页
            if (this.PageCount % this.DigitalPageSize == 0)
            {
                this.DigitalPageCount = this.PageCount / this.DigitalPageSize;
            }
            else
            {
                this.DigitalPageCount = this.PageCount / this.DigitalPageSize + 1;
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("<div id=\"pagerList\">");
            //分页数据信息
            if (outPageCount)
            {
                if (this.PageRecordCount > 0 && this.PageRecordCount < this.PageSize)
                {
                    sb.AppendFormat("共 {0} 条,每页 {1}/{2} 条,第 {3}/{4} 页 ", this.RecordCount, this.PageRecordCount, this.PageSize, this.PageCurrent, this.PageCount);
                }
                else
                {
                    sb.AppendFormat("共 {0} 条,每页 {1} 条,第 {2}/{3} 页 ", this.RecordCount, this.PageSize, this.PageCurrent, this.PageCount);
                }
            }
            else
            {
                sb.AppendFormat("共 {0} 条,每页 {1} 条,第 {2}/{3} 页 ", this.RecordCount, this.PageSize, this.PageCurrent, this.PageCount);
            }
            //判断并确认数据分页模式
            var jsFunName = "DawnPagerHandlerOf";

            switch (pagerType)
            {
            case PagerType.Ajax:
                jsFunName = "DawnPagerHandlerOf";
                break;

            case PagerType.Mvc:
                jsFunName = "DawnPagerMvcOf";
                break;

            case PagerType.Url:
                jsFunName = "DawnPagerUrlOf";
                break;
            }
            //上一页
            if (this.PageCurrent > 1)
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">上一页</a>", jsFunName, this.PageCurrent - 1, parameter);
            }
            //首页
            if (this.PageCurrent > this.DigitalPageFlag + 1)
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}(1,'{1}');\">1</a>...", jsFunName, parameter);
            }
            //输出数字分页
            int number = 0;

            if (this.PageCurrent - this.DigitalPageFlag >= 1)
            {
                number = this.PageCurrent - this.DigitalPageFlag;
            }
            else
            {
                number = 1;
            }
            for (int i = number; i < number + this.DigitalPageSize && i <= this.PageCount; i++)
            {
                if (i == this.PageCurrent)
                {
                    sb.AppendFormat("<span class=\"current\">{0}</span>", i);
                }
                else
                {
                    sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">{1}</a>", jsFunName, i, parameter);
                }
            }
            //末页
            if (this.PageCurrent < this.PageCount - this.DigitalPageFlag && this.PageCurrent > this.DigitalPageSize)
            {
                sb.AppendFormat("...<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">{1}</a>", jsFunName, this.PageCount, parameter);
            }
            //下一页
            if (this.PageCurrent < this.PageCount)
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">下一页</a>", jsFunName, this.PageCurrent + 1, parameter);
            }
            //跳转功能
            if (outPageGoto)
            {
                sb.AppendFormat("<span class=\"gotoarea\"><input type=\"hidden\" id=\"hidPagerMax\" value=\"{0}\" /><input type=\"text\" id=\"txtPagerIndex\" value=\"{4}\" /><label onclick=\"{1}('{2}','{3}');\">跳转</label></span>", this.PageCount, outPageGotoFun, jsFunName, parameter, this.PageCurrent);
            }
            sb.Append("</div>");
            return(sb.ToString());
        }
Пример #6
0
 protected override void Discover()
 {
     if (this.Text.IndexOf('?') != -1)
     {
         this.PageParams = this.Config.tagregex.getBaseParams(this.Text);
         if (!string.IsNullOrEmpty(PageParams))
         {
             string[] arr   = PageParams.Split('&');
             string[] pm    = null;
             string   name  = null;
             string   value = null;
             foreach (string s in arr)
             {
                 if (s.IndexOf('=') != -1)
                 {
                     pm = s.Split('=');
                     if (pm.Length > 1)
                     {
                         name  = pm[0].ToLower();
                         value = pm[1];
                         if (string.IsNullOrEmpty(value))
                         {
                             continue;
                         }
                         if (name == "type" && value == "js")
                         {
                             this.type = PagerType.js;
                         }
                         else if (name == "edge")
                         {
                             int.TryParse(value, out Num_edge);
                         }
                         else if (name == "next")
                         {
                             Next_text = value;
                         }
                         else if (name == "num_display")
                         {
                             int.TryParse(name, out Num_display);
                         }
                         else if (name == "prev")
                         {
                             Prev_text = value;
                         }
                         else if (name == "next_prev_show")
                         {
                             PrevOrNext_show = value == "true";
                         }
                         else if (name == "allways_show")
                         {
                             Allways_show = value == "true";
                         }
                         else if (name == "ellipse")
                         {
                             Ellipse_text = value;
                         }
                         else if (name == "dom")
                         {
                             Dom = value;
                         }
                         else if (name == "domid")
                         {
                             Dom_ID = value;
                         }
                         else if (name == "domclass")
                         {
                             Dom_Class = value;
                         }
                     }
                 }
             }
         }
     }
 }
Пример #7
0
 /// <summary>
 /// Add Page
 /// </summary>
 private void InitPART_Content()
 {
     PageCountText    = PageCount.ToString();
     this.CurrentPage = 1;
     SetNextpageAndPreviouspageState();
     this.PART_Content.Children.RemoveRange(0, PART_Content.Children.Count);
     this.mCurrentPagers.RemoveRange(0, mCurrentPagers.Count);
     if ((this.PageCount <= PageNumber))
     {
         this.mPagerType = PagerType.Default;
         for (int i = 0; i < this.PageCount; i++)
         {
             var pagenumBtn = new Button()
             {
                 Content             = (i + 1).ToString(),
                 Width               = 17,
                 Margin              = new Thickness(2, 0, 2, 0),
                 BorderThickness     = new Thickness(1, 0, 0, 0),
                 VerticalAlignment   = VerticalAlignment.Center,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 Style               = Application.Current.FindResource("PageNumberButton") as Style
             };
             this.mCurrentPagers.Add((i + 1));
             pagenumBtn.Click += PagenumBtn_Click;
             if (this.PART_Content != null)
             {
                 this.PART_Content.Children.Add(pagenumBtn);
             }
         }
     }
     else
     {
         this.mPagerType = PagerType.Complex;
         for (int i = 0; i < PageNumber; i++)
         {
             var pagenumBtn = new Button()
             {
                 Content             = (i + 1).ToString(),
                 Width               = 17,
                 Margin              = new Thickness(2, 0, 2, 0),
                 BorderThickness     = new Thickness(1, 0, 0, 0),
                 VerticalAlignment   = VerticalAlignment.Center,
                 HorizontalAlignment = HorizontalAlignment.Center,
                 Style               = Application.Current.FindResource("PageNumberButton") as Style
             };
             pagenumBtn.Click += PagenumBtn_Click;
             if (i.Equals(0))
             {
                 pagenumBtn.Tag = 1;               //Set the left control point
             }
             if (i.Equals(PageNumber - 1))
             {
                 pagenumBtn.Tag = PageNumber;                            //Set the right control point
             }
             this.mCurrentPagers.Add((i + 1));
             if (this.PART_Content != null)
             {
                 this.PART_Content.Children.Add(pagenumBtn);
             }
         }
     }
     SetLinkButtonFocus(0);
 }
Пример #8
0
 protected override void Discover()
 {
     if (this.Text.IndexOf('?') != -1)
     {
         this.PageParams = this.Config.tagregex.getBaseParams(this.Text);
         if (!string.IsNullOrEmpty(PageParams))
         {
             string[] arr = PageParams.Split('&');
             string[] pm = null;
             string name = null;
             string value = null;
             foreach (string s in arr)
             {
                 if (s.IndexOf('=') != -1)
                 {
                     pm = s.Split('=');
                     if (pm.Length > 1)
                     {
                         name = pm[0].ToLower();
                         value = pm[1];
                         if (string.IsNullOrEmpty(value))
                         {
                             continue;
                         }
                         if (name == "type" && value == "js")
                         {
                             this.type = PagerType.js;
                         }
                         else if (name == "edge")
                         {
                             int.TryParse(value, out Num_edge);
                         }
                         else if (name == "next")
                         {
                             Next_text = value;
                         }
                         else if (name == "num_display")
                         {
                             int.TryParse(name, out Num_display);
                         }
                         else if (name == "prev")
                         {
                             Prev_text = value;
                         }
                         else if (name == "next_prev_show")
                         {
                             PrevOrNext_show = value == "true";
                         }
                         else if (name == "allways_show")
                         {
                             Allways_show = value == "true";
                         }
                         else if (name == "ellipse")
                         {
                             Ellipse_text = value;
                         }
                         else if (name == "dom")
                         {
                             Dom = value;
                         }
                         else if (name == "domid")
                         {
                             Dom_ID = value;
                         }
                         else if (name == "domclass")
                         {
                             Dom_Class = value;
                         }
                     }
                 }
             }
         }
     }
 }
Пример #9
0
        /// <summary>
        /// 输出分页HTML标记
        /// <remarks>
        /// <para>数字链接分页·无地址[Ajax、MVC、静态URL]</para>
        /// <para>默认每页9链接,必须为单数</para>
        /// <para>格式:上一页 1 2...10 下一页</para>
        /// <para>引用 DawnPagerUI.css 文件</para>
        /// <para>引用 DawnPagerJS.js 文件</para>
        /// </remarks>
        /// </summary>
        /// <param name="parameter">URL参数,分页模式的特定格式,详见JS文件</param>
        /// <param name="outPageCount">是否输出实时页总条数,需要给PageRecordCount实时赋值</param>
        /// <param name="pagerType">数据分页模式</param>
        /// <returns>HTML</returns>
        public string ShowPagerByScriptByNumericOf(string parameter, bool outPageCount, PagerType pagerType)
        {
            //计算数字分页
            if (this.PageCount % this.DigitalPageSize == 0)
            {
                this.DigitalPageCount = this.PageCount / this.DigitalPageSize;
            }
            else
            {
                this.DigitalPageCount = this.PageCount / this.DigitalPageSize + 1;
            }
            StringBuilder sb = new StringBuilder();

            sb.Append("<div id=\"pagerList\">");
            //分页数据信息
            if (outPageCount)
            {
                if (this.PageRecordCount > 0 && this.PageRecordCount < this.PageSize)
                {
                    sb.AppendFormat("Total: {0}, Per: {1}/{2}, Page: {3}/{4}&nbsp;&nbsp;", this.RecordCount, this.PageRecordCount, this.PageSize, this.PageCurrent, this.PageCount);
                }
                else
                {
                    sb.AppendFormat("Total: {0}, Per: {1}, Page: {2}/{3}&nbsp;&nbsp;", this.RecordCount, this.PageSize, this.PageCurrent, this.PageCount);
                }
            }
            else
            {
                sb.AppendFormat("Total: {0}, Per: {1}, Page: {2}/{3}&nbsp;&nbsp;", this.RecordCount, this.PageSize, this.PageCurrent, this.PageCount);
            }
            //判断并确认数据分页模式
            var jsFunName = "DawnPagerHandler";

            switch (pagerType)
            {
            case PagerType.Ajax:
                jsFunName = "DawnPagerHandlerOf";
                break;

            case PagerType.Mvc:
                jsFunName = "DawnPagerMvcOf";
                break;

            case PagerType.Url:
                jsFunName = "DawnPagerUrlOf";
                break;
            }
            //上一页
            if (this.PageCurrent > 1)
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">Prev</a>", jsFunName, this.PageCurrent - 1, parameter);
            }
            //首页
            if (this.PageCurrent > this.DigitalPageFlag + 1)
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}(1,'{1}');\">1</a>...", jsFunName, parameter);
            }
            //输出数字分页
            int number = 0;

            if (this.PageCurrent - this.DigitalPageFlag >= 1)
            {
                number = this.PageCurrent - this.DigitalPageFlag;
            }
            else
            {
                number = 1;
            }
            for (int i = number; i < number + this.DigitalPageSize && i <= this.PageCount; i++)
            {
                if (i == this.PageCurrent)
                {
                    sb.AppendFormat("<span class=\"current\">{0}</span>", i);
                }
                else
                {
                    sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">{1}</a>", jsFunName, i, parameter);
                }
            }
            //末页
            if (this.PageCurrent < this.PageCount - this.DigitalPageFlag && this.PageCurrent > this.DigitalPageSize)
            {
                sb.AppendFormat("...<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">{1}</a>", jsFunName, this.PageCount, parameter);
            }
            //下一页
            if (this.PageCurrent < this.PageCount)
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">Next</a>", jsFunName, this.PageCurrent + 1, parameter);
            }
            sb.Append("</div>");
            return(sb.ToString());
        }
Пример #10
0
        /// <summary>
        /// 输出分页HTML标记
        /// <remarks>
        /// <para>方向链接分页·无地址[Ajax、MVC、静态URL]</para>
        /// <para>格式:首页 上一页 下一页 末页</para>
        /// <para>引用 DawnPagerUI.css 文件</para>
        /// <para>引用 DawnPagerJS.js 文件</para>
        /// </remarks>
        /// </summary>
        /// <param name="parameter">URL参数,分页模式的特定格式,详见JS文件</param>
        /// <param name="outPageCount">是否输出实时页总条数,需要给PageRecordCount实时赋值</param>
        /// <param name="showSelect">是否输出页码选择器</param>
        /// <param name="pagerType">数据分页模式</param>
        /// <returns>HTML</returns>
        public string ShowPagerByScriptByForwardOf(string parameter, bool outPageCount, bool showSelect, PagerType pagerType)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<div id=\"pagerList\">");
            //分页数据信息
            if (outPageCount)
            {
                if (this.PageRecordCount > 0 && this.PageRecordCount < this.PageSize)
                {
                    sb.AppendFormat("Total: {0}, Per: {1}/{2}, Page: {3}/{4}&nbsp;&nbsp;", this.RecordCount, this.PageRecordCount, this.PageSize, this.PageCurrent, this.PageCount);
                }
                else
                {
                    sb.AppendFormat("Total: {0}, Per: {1}, Page: {2}/{3}&nbsp;&nbsp;", this.RecordCount, this.PageSize, this.PageCurrent, this.PageCount);
                }
            }
            else
            {
                sb.AppendFormat("Total: {0}, Per: {1}, Page: {2}/{3}&nbsp;&nbsp;", this.RecordCount, this.PageSize, this.PageCurrent, this.PageCount);
            }
            //判断并确认数据分页模式
            var jsFunName = "DawnPagerHandler";

            switch (pagerType)
            {
            case PagerType.Ajax:
                jsFunName = "DawnPagerHandlerOf";
                break;

            case PagerType.Mvc:
                jsFunName = "DawnPagerMvcOf";
                break;

            case PagerType.Url:
                jsFunName = "DawnPagerUrlOf";
                break;
            }
            //首页
            if (this.PageCurrent == 1)
            {
                sb.Append("<span>First</span>");
            }
            else
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}(1,'{1}');\">First</a>", jsFunName, parameter);
            }
            //上一页
            if (this.PageCurrent <= 1)
            {
                sb.Append("&nbsp;&nbsp;<span>Prev</span>&nbsp;&nbsp;");
            }
            else
            {
                sb.AppendFormat("&nbsp;&nbsp;<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">Prev</a>&nbsp;&nbsp;", jsFunName, this.PageCurrent - 1, parameter);
            }
            //下一页
            if (this.PageCurrent >= this.PageCount)
            {
                sb.Append("<span>Next</span>&nbsp;&nbsp;");
            }
            else
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">Next</a>&nbsp;&nbsp;", jsFunName, this.PageCurrent + 1, parameter);
            }
            //末页
            if (this.PageCurrent == this.PageCount | this.PageCount == 0)
            {
                sb.Append("<span>Last</span>");
            }
            else
            {
                sb.AppendFormat("<a href=\"javascript:void(0);\" onclick=\"{0}({1},'{2}');\">Last</a>", jsFunName, this.PageCount, parameter);
            }
            //页码选择器
            if (showSelect)
            {
                sb.AppendFormat("&nbsp;&nbsp;<select onchange=\"{0}(this.value,'{1}');\">", jsFunName, parameter);
                for (int i = 1; i <= this.PageCount; i++)
                {
                    if (i == this.PageCurrent)
                    {
                        sb.AppendFormat("<option value=\"{0}\" selected=\"selected\">{0}</option>", i);
                    }
                    else
                    {
                        sb.AppendFormat("<option value=\"{0}\">{0}</option>", i);
                    }
                }
                sb.Append("</select>");
            }
            sb.Append("</div>");
            return(sb.ToString());
        }