本文介绍了分页帮手asp.net的MVC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经实现分页HTML辅助(改编自史蒂芬·桑德森的书)。这是当前code:

I have implemented a paging html helper (adapted from steven sanderson's book). This is the current code:

公共静态字符串PageLinks(这个HTML的HtmlHelper,诠释当前页,INT总页数,Func键PAGEURL)
        {
            StringBuilder的结果=新的StringBuilder();

public static string PageLinks(this HtmlHelper html, int currentPage, int totalPages, Func pageUrl) { StringBuilder result = new StringBuilder();

        for (int i = 1; i <= totalPages; i++)
        {
            TagBuilder tag = new TagBuilder("a");
            tag.MergeAttribute("href", pageUrl(i));
            tag.InnerHtml = i.ToString();
            if (i == currentPage)
                tag.AddCssClass("selectedPage");
            result.AppendLine(tag.ToString());
        }

        return result.ToString();
    }

这产生了一堆的链接,我的项目每一页。如果有许多页面这可能是一个有点势不可挡。我找了一个类似的实现,它产生较少的压倒性这样的:

This produces a bunch of links to each page of my items. If there are many pages this can be a bit overwhelming. I am looking for a similar implementation which produces something less overwhelming like this:

,其中6是当前页面。我相信有人一定已经实现了类似的东西...之前我必须重新实现轮子。

where 6 is the current page. I am sure someone must have implemented something similar ... before I have to re-implement the wheel.

感谢。

基督教

推荐答案

有一个的nofollow的>寻呼机帮手。

There's a pager helper in MVCContrib.

这篇关于分页帮手asp.net的MVC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 02:33