Git Product home page Git Product logo

mvcbreadcrumbs's Introduction

MvcBreadCrumbs

MvcBreadCrumbs is a NuGet package that allows you to specify custom bread crumb definitions at the controller and route level.

Integrating MvcBreadCrumbs into your web project

It's simple:

  1. Install the Nuget package MvcBreadCrumbs.
  2. Modify your _layout.cshtml to display the breadcrumb links
  3. Start adding the BreadCrumb attribute to your controllers.

By default MvcBreadCrumbs ignores all Http Methods except for GET.

Sample _Layout.cshtml snipet

By default, the MvcBreadCrumbs will display as a ul/li/anchor with the appropriate class name to have BootStrap style the breadcrumb for you. You can thank me later.

@Html.Raw(BreadCrumb.Display())

Sample BreadCrumbs

This sample will display bread crumbs for all routes using the Action name as the BreadCrumb label.

[BreadCrumb]
public class SampleController : Controller
{
    public ActionResult Index()
    {
        return View();
    }
}

This sample demostrates how MvcBreadCrumb will clear the bread crumb stack and add a new entry with the label "Widgets" instead of the default label "Index".

public class SampleController : Controller
{
    [BreadCrumb(Clear = true, Label = "Widgets")]
    public ActionResult Index()
    {
        return View();
    }
}

This sample shows how you can control the bread crumb label directly with data from your model.

public class SampleController : Controller
{
    [BreadCrumb]
    public ActionResult GetProduct(int id)
    {
        var model = db.GetProduct(id);
        BreadCrumb.SetLabel("Product " + model.ProductName);
        return View(model);
    }
}

This sample demostrates how to clear the current breadcrumb stack with code and also how to push a custom URL onto the stack with code.

public class SampleController : Controller
{
    public ActionResult ClearIt()
    {
        BreadCrumb.Clear();
        BreadCrumb.Add(Url.Action("SomeAction", "Home"), "NewRoot");
        return View();
    }
}

mvcbreadcrumbs's People

Contributors

thelarz avatar gimmemoore avatar rhysjacob avatar bhaselmann avatar jhorv avatar jloucaosilva avatar vavanv avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.