Calling a specific action of a controller on the click of HTML button(Not Submit or Form's post Button) Asp.net MVC
any form that directs your user to url created by
<a href='@Url.Action("{action}", "{controller}")'> click me </a>
or
@using(BeginForm("{action}", "{controller}")
will do what you want.
That can be with a
- form
- button link
It's the destination that matters. The View does not "know" anything about the action or controller. The helper does.
Yogesh
Updated on July 09, 2022Comments
-
Yogesh almost 2 years
When we click a Form's submit button, then action of the controller which is having HTTPPost attribute is called but what if i want to call or perform an action when a normal HTML button is clicked Although following articles
http://www.codeproject.com/Tips/198477/Calling-a-MVC-Controller-and-Action-Method-using-H
HTML button calling an MVC Controller and Action method
tells the approach but both of these are using controller name in view, So view has to know about controller, I am looking for an answer that view wont have to know about controller. because views has to be Independent from Controller, Views should not know about controller So, if you know the answer then please reply