@Html.ActionLink("Application name", "Index", "Home", null, new { @class = "navbar-brand" })
4th Parameter in @Html.ActionLink is routeValues and of object type. This can be used to set query string and manage resulting anchor tag.Following line will render an anchor tag with 3 query string parameters:
@Html.ActionLink("Application name", "Index", "Home", new { page = 1,name="my name",gogs="ola" }, new { @class = "navbar-brand" })
Result: http://localhost:34446/Home/Index/1?name=my%20name&gogs=ola
Similarly following code will return an anchor tag with id in url(not in query string parameter):
@Html.ActionLink("Application name", "Index", "Home", new { id = 1 }, new { @class = "navbar-brand" })
Result: http://localhost:34446/Home/Index/1
No comments:
Post a Comment