Possible Duplicate:
Mvc Html.ActionButton
With ASP.NET MVC 3
I know how to create a link to an action method very easily but what I'd like to know is how do you make a button (when clicked) call a particular action method?
Sachin,
If you're using jquery (which you don't mention but I'll show as it's fairly standard with mvc), you'd do the following:
$('#buttonId').click(function(){
document.location = '@Url.Action("MyAction","MyController")';
});
of course, you'd probably want to use ajax, but this is a basic example.
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