zoukankan      html  css  js  c++  java
  • mvc4 ajax.beginform表单验证

    @{
        Layout = null;
    }
    @model MvcApplication1.Models.User
    @using (Ajax.BeginForm("create", "user", new AjaxOptions
    {
        UpdateTargetId = "bform",
        HttpMethod = "post",
        OnSuccess = "success"
    }))
    {
        <div id="divForm">
            <span>@Html.LabelFor(m => m.UserName)</span> 
            <span>@Html.TextBoxFor(m => m.UserName)</span>
            <span>@Html.ValidationMessageFor(m => m.UserName)</span> 
            <span style="display:block;">
                <input type="submit" value="提交" /></span>
        </div>
        <div id="bform">
            
        </div>
    }
    <link type="text/css" rel="Stylesheet" href="@Url.Content("~/content/site.css")" />
    <script src="@Url.Content("~/Scripts/jquery-1.8.3.min.js")"type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")"type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
    <script type="text/javascript">
        function success(data) {
            $("#bform").html(data);
        }
    </script>

    引用的文件:一个是CSS,一个是jquery,其它三个JS是必须引用的。

  • 相关阅读:
    设计模式学习
    rabbitMQ topic实现广播
    rabbitMQ direct实现广播
    rabbitMQ fanout 实现广播
    rabbitMQ 生产者消费者
    python select 实现IO异步
    python gevent 爬虫
    python gevent socket
    python 协程
    python 进程池
  • 原文地址:https://www.cnblogs.com/subendong/p/4396992.html
Copyright © 2011-2022 走看看