معرفی DNTBreadCrumb
نویسنده: وحید نصیری
تاریخ: ۱۳۹۵/۰۱/۰۱ ۸:۵
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
PM> install-package DNTBreadCrumb
@{Html.RenderPartial("_BreadCrumb");} [BreadCrumb(Title = "News Root", UseDefaultRouteUrl = true, RemoveAllDefaultRouteValues = true,
Order = 0, GlyphIcon = "glyphicon glyphicon-link")]
public class NewsController : Controller
{
[BreadCrumb(Title = "Main index", Order = 1)]
public ActionResult Index(string id)
{
if (!string.IsNullOrWhiteSpace(id))
{
this.SetCurrentBreadCrumbTitle(id);
}
return View();
} [BreadCrumb(Title = "News Archive", Order = 2)]
public ActionResult Archive(int? id)
{
if (id != null)
{
this.SetCurrentBreadCrumbTitle(string.Format("News item {0}", id.Value));
this.AddBreadCrumb(new BreadCrumb
{
Title = "News Archive",
Order = 1,
Url = Url.Action("Archive", "News", routeValues: new { id = "" })
});
}
return View();
}
this.AddBreadCrumb(new BreadCrumb
{
Title = categoryname.Title,
Order = 1,
Url = Url.Action("Index", "ProductList", new { catid = categoryname.Id }),
ForceUrl = true
});
this.AddBreadCrumb(new BreadCrumb
{
Title = result.Title,
Order = 2,
ForceUrl = false
}); routes.MapRoute(
"category_route", // Route name
"MyControllerName/{category}/{productname}", // URL with parameters
new { controller = "MyControllerName", action = "MyActionName",
category = UrlParameter.Optional, productname = UrlParameter.Optional, area = "" }
);