MVC按钮点击动作 [英] MVC button click to action
本文介绍了MVC按钮点击动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:结果
的mvc Html.ActionButton
使用 ASP.NET MVC 3
我知道如何创建一个链接很容易的操作方法,但想什么,我知道的是你如何让一个按钮(点击时)调用某个特定的操作方法?
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?
推荐答案
萨钦,
如果你正在使用jQuery(你不提,但我会显示为它与MVC相当标准),你会做以下内容:
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")';
});
当然,你可能想使用AJAX,但是这是一个基本的例子。
of course, you'd probably want to use ajax, but this is a basic example.
这篇关于MVC按钮点击动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文