Quote from MSDN:
RouteLink returns an anchor element (a element) that contains the virtual path of the specified action.
It means it will generate following html a tag
<a href="myserver/Product/List...">linkstring</a>
質問
I'm reading Adam's book Pro ASP .NET MVC 4 and I have a question what does this code do?
@Html.RouteLink(link, new
{
controller = "Product",
action = "List",
category = link,
page = 1
},
new {
@class = link == ViewBag.SelectedCategory ? "selected" : null
})
Additionally, I have a controller with the method inside
public PartialViewResult Menu(string category = null)
{
ViewBag.SelectedCategory = category;
IEnumerable<string> categories = repository.Products
.Select(x => x.Category)
.Distinct()
.OrderBy(x => x);
return PartialView(categories);
}
Thank you for your help!
解決
Quote from MSDN:
RouteLink returns an anchor element (a element) that contains the virtual path of the specified action.
It means it will generate following html a tag
<a href="myserver/Product/List...">linkstring</a>