本文整理汇总了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;
}
}
示例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();
}
示例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);
}