Beispiel #1
0
        public void BindControls(PagerData pagerData)
        {
            pagerData.CurrentPageID = hdfCurrentPage.ClientID;

            pagerData.PageIndex = (CurrentPage - 1);
            pagerData.Type      = "Prev";
            hrefPrevious.Attributes.Add("onclick", "javascript:pageIndexClick(" + (new JavaScriptSerializer()).Serialize(pagerData) + "); return false;");

            pagerData.PageIndex = 0;
            pagerData.Type      = "First";
            hrefFirst.Attributes.Add("onclick", "javascript:pageIndexClick(" + (new JavaScriptSerializer()).Serialize(pagerData) + "); return false;");

            if (hrefNum1.Visible == true)
            {
                pagerData.PageIndex = (Convert.ToInt32(hrefNum1.InnerText) - 1);
                pagerData.Type      = "";
                hrefNum1.Attributes.Add("onclick", "javascript:pageIndexClick(" + (new JavaScriptSerializer()).Serialize(pagerData) + "); return false;");
            }
            if (hrefNum2.Visible == true)
            {
                pagerData.PageIndex = (Convert.ToInt32(hrefNum2.InnerText) - 1);
                pagerData.Type      = "";
                hrefNum2.Attributes.Add("onclick", "javascript:pageIndexClick(" + (new JavaScriptSerializer()).Serialize(pagerData) + "); return false;");
            }
            if (hrefNum3.Visible == true)
            {
                pagerData.PageIndex = (Convert.ToInt32(hrefNum3.InnerText) - 1);
                pagerData.Type      = "";
                hrefNum3.Attributes.Add("onclick", "javascript:pageIndexClick(" + (new JavaScriptSerializer()).Serialize(pagerData) + "); return false;");
            }
            if (hrefNum4.Visible == true)
            {
                pagerData.PageIndex = (Convert.ToInt32(hrefNum4.InnerText) - 1);
                pagerData.Type      = "";
                hrefNum4.Attributes.Add("onclick", "javascript:pageIndexClick(" + (new JavaScriptSerializer()).Serialize(pagerData) + "); return false;");
            }
            if (hrefNum5.Visible == true)
            {
                pagerData.PageIndex = (Convert.ToInt32(hrefNum5.InnerText) - 1);
                pagerData.Type      = "";
                hrefNum5.Attributes.Add("onclick", "javascript:pageIndexClick(" + (new JavaScriptSerializer()).Serialize(pagerData) + "); return false;");
            }
            pagerData.PageIndex = (_lastPage - 1);
            pagerData.Type      = "Last";
            hrefLast.Attributes.Add("onclick", "javascript:pageIndexClick(" + (new JavaScriptSerializer()).Serialize(pagerData) + "); return false;");

            pagerData.PageIndex = CurrentPage;
            pagerData.Type      = "Next";
            hrefNext.Attributes.Add("onclick", "javascript:pageIndexClick(" + (new JavaScriptSerializer()).Serialize(pagerData) + "); return false;");
        }
        public static string RenderPagerHTML(string usercontrolPath, UserControls.PagerData pager, int totalCount)
        {
            System.Web.UI.Page page    = new System.Web.UI.Page();
            UserControls.Pager ucPager = (UserControls.Pager)page.LoadControl(usercontrolPath + "/Pager.ascx");
            System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
            if (ucPager != null)
            {
                ucPager.CurrentPage  = pager.CurrentPage;
                ucPager.PageSize     = pager.PageSize;
                ucPager.RowCount     = totalCount;
                ucPager.AllowPaging  = false;
                ucPager.SelectMethod = pager.SelectMethod;
                ucPager.doPaging();
                form.Controls.Add(ucPager);
            }
            page.Controls.Add(form);
            foreach (System.Web.UI.Control ctrlpage in page.Controls)
            {
                foreach (System.Web.UI.Control ctrl in ctrlpage.Controls)
                {
                    UserControls.Pager ucPager1 = ctrl as UserControls.Pager;
                    if (ucPager1 != null)
                    {
                        ucPager1.BindControls(pager);
                        break;
                    }
                }
            }

            StringWriter textWriter = new StringWriter();

            HttpContext.Current.Server.Execute(page, textWriter, false);
            string htmlData = CleanHtml(textWriter.ToString());

            textWriter.Close();
            return(htmlData);
        }