Hi, I want to invoke an action (which is in HomeController) on link button click? The link button is present on a empty View which I have added to Views which is not a stronly typed view?
regards, kapil
Hi, I want to invoke an action (which is in HomeController) on link button click? The link button is present on a empty View which I have added to Views which is not a stronly typed view?
regards, kapil
If you want to use a button then it needs its own form and the form helper method needs to show the controler and action you are using.
<% using (Html.BeginForm("ActionName", "ControllerName" )) { %>
<input type="submit" value="Run Action" />
<% } %>
Or, if you want to just use a text link then you can use this:
<%= Html.ActionLink("Link text", "ActionName", "ControllerName"); %>
If your view is for the same controler as the action you want to direct to then you do not need to specify the controller name.
If you wish to pass extra info to the action method you can pass an anonymous object like this:
<%= Html.ActionLink("Link text", "ActionName", "ControllerName", new {variableName="a value", anotherVariableName=78}); %>