我如何在MVC4中执行提交按钮操作 [英] How do I do have a Submit Button action in MVC4

查看:49
本文介绍了我如何在MVC4中执行提交按钮操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在MVC4中执行提交按钮操作?



 @ Using(Html.BeginForm( 输出  Home,FormMethod.Post))
...
//提交按钮
结束 < span class =code-keyword>使用

解决方案

表单上的任何类型按钮都会导致表单提交。



 <  按钮 > 提交<   /按钮 >  





您还可以拥有类型提交按钮



 <  输入   类型  = 提交    value   = 提交    /  >  





或者,您可以具有ID或类的按钮,并使用javascript捕获单击。在这种情况下,您可以通过javascript提交,或者只是调用您的表单提交操作。



 

function (){


#submit_it)。click( function (){
// 在这里工作
return false ;
});
});



 <  按钮    id   =  submit_it  > 提交<   / button  >  


How do I do have a Submit Button action in MVC4?

@Using (Html.BeginForm("Output", "Home", FormMethod.Post))
    ...
   //Submit button
End Using

解决方案

Anything of type button on the form will cause the form to submit.

<button>Submit</button>



You can also have a button of type submit

<input type="submit" value="Submit" />



Alternately, you can have buttons with an ID or class, and catch the click with javascript. In that case, you can either submit via javascript, or just call your forms submit action.


(function(){


("#submit_it").click(function(){ //do work here return false; }); });


<button id="submit_it">Submit</button>


这篇关于我如何在MVC4中执行提交按钮操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆