Reputation: 3423
I have a table in my database which stores events. I am currently on my Homecontroller's index view page and I need to post a link to the edit method of my EventsController which takes in the ID of an event and edits it. Can I do this:-
@Html.ActionLink("Edit", "~/Controllers/EventsController.cs/Edit", new { id=item.ID })
or do I have to write something else to achieve my motive. Thanks.
Upvotes: 1
Views: 247
Reputation: 133403
You can use
@Html.ActionLink("Edit", "Edit", "Events", new { id=item.ID }, null)
You can use overload, LinkExtensions.ActionLink Method (HtmlHelper, String, String, String, Object, Object)
For more info visit LinkExtensions.ActionLink
Upvotes: 4
Reputation: 112
You can use the code as
@Html.ActionLink("Edit", "EventsController", new { id=item.ID })
There are different overloads available for "ActionLink", check them out. eg.
In case you controller is placed in some different location (may be because of area ), you will have to specify it.
Upvotes: 2
Reputation: 3279
You can use following:
@Html.ActionLink("Link Text", "Edit", "Events", new { id=item.ID })
Upvotes: 1