3
Answers

how to get breadcrumbs path in li html mvc anchor tag

Here is my example:
  1. <ul>  
  2.         <li><a href="GrandParent.html">Grand Parent</a>  
  3.             <ul>  
  4.                 <li><a href="Parent.html">Parent</a>  
  5.                     <ul>  
  6.                         <li><a href="child.html">child</a></li></ul>  
  7.                 </li>  
  8.             </ul>  
  9.         </li>  
  10.     </ul>  
 

every li element has a anchor tag next to it (not shown in the code, please assume that).

Now if a select value "Child" from the above code then i should get the below result "Grand Parent/ Parent / Child" and if i select parent then i should get "Grand Parent / Parent"

So basically the i want to get parent with all its child

Here is my code:

  1. @helper GetTreeView(Abacus_CMS.Models.AbacusModel siteMenu, int parentID)  
  2.     {  
  3.     var url = new System.Web.Mvc.UrlHelper(Context.Request.RequestContext);  
  4.     foreach (var i in siteMenu.AbacusMenuList.Where(a => a.ParentCatagoryId.Equals(parentID)))  
  5.     {  
  6.             <li>  
  7.                 @{ var submenu = siteMenu.AbacusMenuList.Where(a => a.ParentCatagoryId.Equals(i.Id)).Count();}  
  8.                 @if (submenu > 0)  
  9.                 {  
  10.   
  11.                 <li style="margin-left: -6px;">  
  12.                     <a href="@url.RouteUrl("GettingStarted", new { catname = HttpUtility.UrlEncode(i.Name.Replace(' ', '-'))})" id="@i.Name.Replace(' ', '-').ToLower()" onclick="GetParents()">  
  13.                         <i class="fa fa-chevron-right" aria-hidden="true"style="margin-left: 25px; font-size: 10px;">   
  14.                         </i><span class="title" style="margin-left: 0px;">@i.Name</span>  
  15.                         <span class="arrow " style="height: 4px;"></span>  
  16.   
  17.                     </a>  
  18.                     <ul class="sub-menu">  
  19.                         @treeview.GetTreeView(siteMenu, i.Id)  
  20.                         @* Recursive  Call for Populate Sub items here*@  
  21.                     </ul>  
  22.                 </li>  
  23.   
  24.                 @*<span class="collapse collapsible"> </span>*@  
  25.                 }  
  26.                 else  
  27.                 {  
  28.                     <a href="@url.RouteUrl("GettingStarted", new { catname = HttpUtility.UrlEncode(i.Name.Replace(' ', '-')) })" style="margin-left: 30px;" id="@i.Name.Replace(' ', '-').ToLower()">  
  29.   
  30.                             @i.Name  
  31.                         </a>  
  32.                         }  
  33.   
  34.                         </li>  
  35.   
  36.                 }  
  37.                 }  
how to Get breadcrumb path as text?? 
Answers (3)