using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Web;
 using System.Web.Mvc;

 namespace MvcValidateDemo.Controllers
 {
     public class AjaxController : Controller
     {
         //
         // GET: /Ajax/

         public ActionResult Index()
         {
             return View();
         }

         public ActionResult GetDate()
         {
             //让网站睡眠1秒钟
             System.Threading.Thread.Sleep();
             return Content(DateTime.Now.ToString());
         }

         public ActionResult MicrosoftAjax()
         {
             return View();
         }

     }
 }
 @{
     Layout = null;
 }

 <!DOCTYPE html>

 <html>
 <head>
     <meta name="viewport" content="width=device-width" />
     <title>MicrosoftAjax</title>
     <script src="~/Scripts/jquery-1.8.2.js"></script>
     <script src="~/Scripts/jquery.unobtrusive-ajax.js"></script>
     <script type="text/javascript">
         function afterSuccess(data) {
             //alert(data);
         }
     </script>
 </head>
 <body>
     <div>
         @using (Ajax.BeginForm("GetDate", "Ajax", new AjaxOptions(){Confirm  ="您是否要提交吗?",HttpMethod = "Post",InsertionMode = InsertionMode.InsertAfter,UpdateTargetId = "result",OnSuccess="afterSuccess",LoadingElementId = "loading"}))
         {
             <div>
                 用户名:<input type="text" name="UserName" /><br />
                 密码:<input type="text" name="Pwd"/><br />
                 <input type="submit" value="提交"/>
             </div>
         }

         <div id="result">

         </div>

         <div id="loading" style="display:none">
             <img src="~/Content/ico_loading2.gif" />
         </div>
     </div>
 </body>
 </html>

mvc自带的异步表单提交的更多相关文章

  1. 使用jquery form插件进行异步带文件的表单提交

    引入form插件与jquery 的js文件后 获取表单的jq对象 然后.ajaxSubmit提交表单即可 实现添加品牌的异步表单提交 function addBarandImg(formId) { $ ...

  2. mvc area区域和异步表单,bootstrap简单实例

    码农最怕眼高手低 今天来练习mvc Area技术和bootstrap以及异步表单的C#代码实现. 1.area区域架构对于建立复杂业务逻辑很有帮助,由  AreaRegistration.Regist ...

  3. asp.net mvc 模型验证注解,表单提交

    一.添加模型 public class Account { public int ID { get; set; } [Display(Name = "姓名")] //设置要显示的字 ...

  4. jQuery异步表单提交

    有时在A页面点击按钮弹出一个form表单,在填完表单后提交成功后,需要关闭表单页并将表单中的某些值反应在A页面上,这时就需要异步提交表单.其实也挺简单,只是需要把表单数据序列化. $("#f ...

  5. spring mvc Controller与jquery Form表单提交代码demo

    1.JSP表单 <% String basePath = request.getScheme() + "://" + request.getServerName() +&qu ...

  6. js 记一次带时间的表单提交报400错误

    写一个功能的时候,表单里不填时间提交的时候,数据就正常传到后台了,一填上时间就报400错误,看了后台时间的处理也没问题,看了前端时间控件返回的格式也对,但是就是一直报错, 把提交的数据打印出来也没发现 ...

  7. (转)ASP.NET MVC 第五个预览版和表单提交场景

    转自:http://ourlife.blog.51cto.com/708821/296171 上个星期四,ASP.NET MVC开发团队发布了ASP.NET MVC框架的“第五个预览版”.你可以在这里 ...

  8. MVC下HtmlHelper自带BeginForm表单提交与异步Ajax请求

    假如有一个数据表格UserInfo: public class UserInfo { public int Id { get; set; } public string Name { get; set ...

  9. [Spring MVC] - 表单提交

    Spring MVC自带的表单标签比较简单,很多时候需要借助EL和JSTL来完成. 下面是一个比较简单的表单提交页面功能: 1.User model package com.my.controller ...

随机推荐

  1. 将图片转换为Base64

    string Imagefilename   硬盘路径 protected string ImgToBase64String(string Imagefilename) { try { Bitmap ...

  2. 《python基础教程》笔记之 列表

    list函数 list函数将其他类型的序列转换为列表,如 >>> list("hello world")['h', 'e', 'l', 'l', 'o', ' ' ...

  3. c++ 高效文本读写

    上数据结构课,做project,数据老师要求我们多做测试,而文本文件可以有效记录这些东东,这样我想起了文件的读写,下面是渣渣我个人的一些想法,大神们看见有错的,尽管指出(orz~~~囧,木有人看我的呀 ...

  4. 转:BZERO()等的区别

    BZERO()等的区别 bzero  原型: extern void bzero(void *s, int n); 用法: #include <string.h> 功能:置字节字符串s的前 ...

  5. win8 在哪找画图工具

    把鼠标放在右上角,然后往下拉,出现搜索图标,如图: 在‘搜索’输入‘画图’ 打开即可使用.

  6. BZOJ3564 信号增幅仪

    http://www.lydsy.com/JudgeOnline/problem.php?id=3564 思路:先旋转坐标系,再缩进x坐标,把椭圆变成圆,然后做最小圆覆盖. 还有,为什么用srand( ...

  7. Oracle12c中新建用户

    运行SQLPlus,以  sysdba打开 新建用户需要 create user C##[username] identified by [password] grant dba to C##[use ...

  8. 对Primary-backup分布式数据库分布式一致性的猜想

    昨天读了paxos算法,心里对分布式一致性有一些想法:如果是我,应该怎么实现数据库集群的一致性呢? paxos算法本身并没有提到其应用,所以实际使用情况应该较复杂.而我平时接触到使用分布式一致性算法的 ...

  9. Shell循环处理

    date=`echo $1 | tr -d '-'` date1=`echo $1` date_end=`get_date $2 +1 | sed 's/-//g'` while [ 1 ] do d ...

  10. mysql 索引相关知识

    由where 1 =1 引发的思考 最近工作上被说了 说代码中不能用 where 1=1,当时觉得是应该可以用的,但是找不到什么理据, 而且mysql 语句优化这方面确实很薄弱   感觉自己mysql ...