Search results

Navigation in ASP.NET Core Breadcrumb control

03 Dec 2021 / 2 minutes to read

The Breadcrumb item navigates to the path while clicking the item. To enable navigation, urlproperty was bound to the items.

URL

In the Breadcrumb component, the item represents the url. The Breadcrumb items can be provided with either relative or absolute URL.

Relative URL

The Breadcrumb items with relative URL contain only the path but do not locate the path or server. The following example represents the breadcrumb items with relative url.

Output be like the below.

Breadcrumb Sample

Absolute URL

The Breadcrumb items with absolute URL contain the path and locate to the resource if the static url is bound to the breadcrumb item. The following example represents the breadcrumb items with static url.

tagHelper
default.cs
Copied to clipboard
<ejs-breadcrumb id="separatorTemplate" enableNavigation="false">
<e-breadcrumb-items>
    <e-breadcrumb-item text="Home" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Getting" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Icons" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Navigation" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Overflow" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
</e-breadcrumb-items>
</ejs-breadcrumb>
Copied to clipboard
public ActionResult Index()
{
    return View();
}

Output be like the below.

Breadcrumb Sample

Enable navigation for last Breadcrumb item

The feature enables the last item of the Breadcrumb component by setting the enableActiveItemNavigation property to true. In the following example, the last item of the Breadcrumb was enabled.

tagHelper
default.cs
Copied to clipboard
<ejs-breadcrumb id="default" enableNavigation="false" enableActiveItemNavigation="true">
<e-breadcrumb-items>
    <e-breadcrumb-item text="Home" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Getting" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Icons" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Navigation" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Overflow" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
</e-breadcrumb-items>
</ejs-breadcrumb>
Copied to clipboard
public ActionResult Index()
{
    return View();
}

Output be like the below.

Breadcrumb Sample

Open URL in new page or tab

To open the Breadcrumb item in a new page or tab, set the target property of the required item url to blank in the Breadcrumb component. In the following example, the target property of All Component item url was set to blank by using the beforeItemRender event which locates to the path in the new tab.

tagHelper
default.cs
Copied to clipboard
<ejs-breadcrumb id="separatorTemplate" beforeItemRender="beforeItemRender">
<e-breadcrumb-items>
    <e-breadcrumb-item text="Home" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Getting" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Icons" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Navigation" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
    <e-breadcrumb-item text="Overflow" url="https://ej2.syncfusion.com/home/aspnetcore.html#platform"></e-breadcrumb-item>
</e-breadcrumb-items>
</ejs-breadcrumb>

<script>
    function beforeItemRender(args) {
        if (args.element.children[0]) {
                args.element.children[0].target = "_blank";
            }
    }
</script>
Copied to clipboard
public ActionResult Index()
{
    return View();
}

Output be like the below.

Breadcrumb Sample