Friday, 24 July 2015

HTML.ActionLink MVC

The actionlink method renders a hyperlink (anchor tag) to another controller action.

e.g When linking to action in the same controller used to render the currentview, you can simply specify the action name;

@html.ActionLink(“Link Text”,”Action”);

This produces the flowing markup.

<a href=“/home/anotheraction”>LinkText</a>

You can specify the action
@Html.ActionLink(“Link Text”, “Index”,”Open”);



You can provide the helper with all the necessary route value using other overloads of action links.
e.g. to build a link to edit an album with an Id of 100

@Html.ActionLink(“Edit Link”,”Edit”,”Store Item”, New{Id = 100},null)

The RouteLink helper follows the same pattern as the ActionLink helper but also accepts a route ActionLink helper, but also accepts a route name & doesn’t have arguments for controller name & action name.

@Html.RouteLink(“Link Text”,new {action =”another Action”});

No comments:

Post a Comment

Others

You will like to read it