Lose.zhang 发表于 2012-12-10 14:13:46

爱上MVC3系列~Html.BeginForm与Ajax.BeginForm

<div id="cnblogs_post_body">Html.BeginForm与Ajax.BeginForm都是MVC架构中的表单元素,它们从字面上可以看到区别,即Html.BeginForm是普通的表单提交,而Ajax.BeginForm是支持异步的表单提交,这对于我们开发者来说是一个福音,我们不用再自己去用JQ代码了,直接用MVC自代的Ajax.BeginForm就可以很容易的完成一个异步的表单提交动作。
Html.BeginForm的原型解释:

<div class="cnblogs_code"> 1 @using (Html.BeginForm()) {} //提交到当前页面 2 3 @using (Html.BeginForm(new {} )) {} //提交到当前页面,并可以传递参数 4 5 @using (Html.BeginForm("action","controller")) {} //提交到指定controller下的action中 6 7 @using (Html.BeginForm("action","controller",FormMethod.POST)) {} //提交到指定controller下的action中,并指定提交方式 8 9 FormMethod枚举如下:   10 11  // 摘要:12   //   枚举窗体的 HTTP 请求类型。13   public enum FormMethod14     {15         // 摘要:16         //   指定 GET 请求。17         Get = 0,18         //19         // 摘要:20         //   指定 POST 请求。21         Post = 1,22   }
页: [1]
查看完整版本: 爱上MVC3系列~Html.BeginForm与Ajax.BeginForm