当前位置: 首页>>代码示例>>C#>>正文


C# PaginatedList.ReturnPager方法代码示例

本文整理汇总了C#中PaginatedList.ReturnPager方法的典型用法代码示例。如果您正苦于以下问题:C# PaginatedList.ReturnPager方法的具体用法?C# PaginatedList.ReturnPager怎么用?C# PaginatedList.ReturnPager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PaginatedList的用法示例。


在下文中一共展示了PaginatedList.ReturnPager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetSearchResults

        private void GetSearchResults()
        {
            // Get the paging variable
            int? p = null;
            if (Request.QueryString["p"] != null)
                p = Convert.ToInt32(Request.QueryString["p"]);

            // Get the search variable
            string s = null;
            if (Request.QueryString["s"] != null)
                s = Request.QueryString["s"];

            if(s != null)
            {
                // Strip out any nasties from the term
                var searchterm = Helpers.SafePlainText(s).ToLower();

                // Get the posts that contain the search
                var posts = Factory.SearchPosts(searchterm).Select(x => x.ParentId);

                // Now get topics the posts are in
                var maintopics = from t in Factory.ReturnAllTopics(true)
                                 where posts.Contains(t.Id)
                                 select t;

                // Pass to my pager helper
                var pagedResults = new PaginatedList<ForumTopic>(maintopics, p ?? 0, Helpers.MainForumSettings().TopicsPerPage);

                // Decide whether to show pager or not
                if (pagedResults.TotalPages > 1)
                {
                    litPager.Text = pagedResults.ReturnPager();
                }

                // Now bind
                rptTopicList.DataSource = pagedResults;
                rptTopicList.DataBind();
            }
            else
            {
                topiclist.Visible = false;
            }
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:43,代码来源:ForumSearchResults.ascx.cs

示例2: GetTopicsFromCategory

        /// <summary>
        /// Gets all the topics from the parent category
        /// </summary>
        private void GetTopicsFromCategory()
        {
            // Before anything see if the category has been marked as private, if so make sure user is loggged in
            var currentCategory = Mapper.MapForumCategory(CurrentNode);
            var userHasAccess = true;
            if (MembershipHelper.IsAuthenticated())
            {
                // Member is logged in so it doesn't matter if forum is private or not,
                // now check they have enough karma to view this category and hide if not
                if (CurrentMember.MemberKarmaAmount < currentCategory.KarmaAccessAmount)
                {
                    userHasAccess = false;
                }
            }
            else
            {
                if (currentCategory.IsPrivate)
                {
                    userHasAccess = false;
                }
            }

            // Check to see if user has access
            if(!userHasAccess)
            {
                Response.Redirect(string.Concat(Settings.Url, "?m=", library.GetDictionaryItem("NoPermissionToViewPage")));
            }

            // Get the paging variable
            int? p = null;
            if (Request.QueryString["p"] != null)
                p = Convert.ToInt32(Request.QueryString["p"]);

            // Set cache variables
            var useNodeFactory = Request.QueryString["nf"] != null;
            var maintopics = from t in Factory.ReturnAllTopicsInCategory(CurrentNode.Id, true, useNodeFactory)
                             where !t.IsSticky
                             select t;

            if(!ShowAll)
            {
                maintopics = maintopics.Take(2);
                btnShowAll.Visible = true;
            }

            // Pass to my pager helper
            var pagedResults = new PaginatedList<ForumTopic>(maintopics, p ?? 0, Convert.ToInt32(Settings.TopicsPerPage));

            // Decide whether to show pager or not
            if (pagedResults.TotalPages > 1)
            {
                litPager.Text = pagedResults.ReturnPager();
            }

            // Now bind
            rptTopicList.DataSource = pagedResults;
            rptTopicList.DataBind();
        }
开发者ID:wakkomail,项目名称:community-framework,代码行数:61,代码来源:Discussions.ascx.cs

示例3: GetTopicPosts

        /// <summary>
        /// Gets the topics and returns them in a pager
        /// </summary>
        private void GetTopicPosts()
        {
            // Get the paging variable
            if (Request.QueryString["p"] != null)
                p = Convert.ToInt32(Request.QueryString["p"]);

            // Before anything see if the category has been marked as private, if so make sure user is loggged in
            var parentCategory = Mapper.MapForumCategory(new Node(ParentTopic.CategoryId));
            var userHasAccess = true;
            if (MembershipHelper.IsAuthenticated())
            {
                // Member is logged in so it doesn't matter if forum is private or not,
                // now check they have enough karma to view this category and hide if not
                if (CurrentMember.MemberKarmaAmount < parentCategory.KarmaAccessAmount)
                {
                    userHasAccess = false;
                }

                // check user has enough karma to be able to post in this category
                if (CurrentMember.MemberKarmaAmount < parentCategory.KarmaPostAmount)
                {
                    lvNewPost.Visible = false;
                }

            }
            else
            {
                if (parentCategory.IsPrivate)
                {
                    userHasAccess = false;
                }
            }
            // Check to see if user has access
            if (!userHasAccess)
            {
                Response.Redirect(string.Concat(Settings.Url, "?m=", library.GetDictionaryItem("NoPermissionToViewPage")));
            }

            //Get all the posts
            var useNodeFactory = Request.QueryString["nf"] != null;
            var topicposts = Factory.ReturnAllPostsInTopic(ParentTopic.Id, useNodeFactory);

            // Pass to my pager helper
            var pagedResults = new PaginatedList<ForumPost>(topicposts, p ?? 0, Convert.ToInt32(Settings.PostsPerPage));

            // Decide whether to show pager or not
            if (pagedResults.TotalPages > 1)
            {
                litPager.Text = pagedResults.ReturnPager();
            }

            // Now bind
            rptTopicPostList.DataSource = pagedResults;
            rptTopicPostList.DataBind();

            // Set the meta description
            var starterPost = Factory.ReturnTopicStarterPost(ParentTopic.Id);

            if (starterPost == null) return;

            var mDesc = Factory.ReturnTopicStarterPost(ParentTopic.Id).Content;
            var metaDescription = new HtmlMeta
                                      {
                                          Name = "description",
                                          Content = library.TruncateString(library.StripHtml(mDesc), 300, "...")
                                      };
            Page.Header.Controls.Add(metaDescription);
        }
开发者ID:wakkomail,项目名称:community-framework,代码行数:71,代码来源:ForumListPostsInTopic.ascx.cs


注:本文中的PaginatedList.ReturnPager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。