相关疑难解决方法(0)

SiteMap HtmlHelper ASP.NET MVC

我重写了这篇文章,以使其更简单.这是我得到的代码(a HtmlHelper):

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Runtime.CompilerServices;
using System.Web.Mvc;
using System.Text;

using System.Web.Routing;

namespace Intranet.Helpers
{
  public static class MenuHelper
  {
    private static string GetBackLink(SiteMapNode parentNode)
    {
      return "<li class='li-back'><a href='" + parentNode.Url + "' title='" + parentNode.Title + "'></a></li>";
    }

    public static string Menu(this HtmlHelper helper)
    {
      var sb = new StringBuilder();
      SiteMapNodeCollection siteMapNodeCollection;
      sb.Append("<ul>");
      SiteMapNode currentNode = SiteMap.CurrentNode;

      if (!SiteMap.CurrentNode.Equals(SiteMap.RootNode))
      {
        if (!SiteMap.CurrentNode.HasChildNodes)
          sb.Append(GetBackLink(SiteMap.CurrentNode.ParentNode.ParentNode));
        else
          sb.Append(GetBackLink(SiteMap.CurrentNode.ParentNode));
      }

      if (!SiteMap.CurrentNode.HasChildNodes)
        siteMapNodeCollection = SiteMap.CurrentNode.ParentNode.ChildNodes; …
Run Code Online (Sandbox Code Playgroud)

sitemap asp.net-mvc

3
推荐指数
2
解决办法
1万
查看次数

标签 统计

asp.net-mvc ×1

sitemap ×1