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
click(function () { //On click of your button var property1 = $('#property1Id'). val(); //Get the values from the page you want to post var property2 = $('#property2Id').
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
It's the destination that matters. The View does not "know" anything about the action or controller. The helper does.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With