Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Here is my example:

HTML
<ul>
        <li><a href="GrandParent.html">Grand Parent</a>
            <ul>
                <li><a href="Parent.html">Parent</a>
                    <ul>
                        <li><a href="child.html">child</a></li></ul>
                </li>
            </ul>
        </li>
    </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:
C#
@helper GetTreeView(Abacus_CMS.Models.AbacusModel siteMenu, int parentID)
 {
 var url = new System.Web.Mvc.UrlHelper(Context.Request.RequestContext);
 foreach (var i in siteMenu.AbacusMenuList.Where(a => a.ParentCatagoryId.Equals(parentID)))
 {
         <li>
             @{ var submenu = siteMenu.AbacusMenuList.Where(a => a.ParentCatagoryId.Equals(i.Id)).Count();}
             @if (submenu > 0)
             {

             <li style="margin-left: -6px;">
                 <a href="@url.RouteUrl("GettingStarted", new { catname = HttpUtility.UrlEncode(i.Name.Replace(' ', '-'))})" id="@i.Name.Replace(' ', '-').ToLower()" onclick="GetParents()">
                     <i class="fa fa-chevron-right" aria-hidden="true"style="margin-left: 25px; font-size: 10px;">
                     </i><span class="title" style="margin-left: 0px;">@i.Name</span>
                     <span class="arrow " style="height: 4px;"></span>

                 </a>
                 <ul class="sub-menu">
                     @treeview.GetTreeView(siteMenu, i.Id)
                     @* Recursive  Call for Populate Sub items here*@
                 </ul>
             </li>

             @*<span class="collapse collapsible">&nbsp;</span>*@
             }
             else
             {
                 <a href="@url.RouteUrl("GettingStarted", new { catname = HttpUtility.UrlEncode(i.Name.Replace(' ', '-')) })" style="margin-left: 30px;" id="@i.Name.Replace(' ', '-').ToLower()">

                         @i.Name
                     </a>
                     }

                     </li>

             }
             }

how to Get breadcrumb path as text??
Posted
Updated 11-Sep-16 20:19pm
v3

1 solution

Use jQuery, there are several snippets you might use: Bootstrap and jQuery breadcrumb Code Examples | Bootsnipp.com[^]

If you cannot do that, you have to take the element clicked and loop through its parents (calling parentElement) and filling some array that you will join when you finish.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900