V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
CBBing
V2EX  ›  问与答

ASP.NET MVC 使用 Ajax 提交表单,后台接收后值为 null?

  •  1
     
  •   CBBing · 2016-05-17 10:32:00 +08:00 · 1897 次点击
    这是一个创建于 3113 天前的主题,其中的信息可能已经有所发展或是发生改变。
    @using (Ajax.BeginForm(ajaxopts))
    {
    @Html.LabelFor(model => model.comment.FileId, htmlAttributes: new { @class = "control-label col-md-2" })
    <input class="form-control text-box single-line" data-val="true" data-val-number="The field FileId must be a number." data-val-required="FileId 字段是必需的。" id="FileId" name="FileId" type="number" value="@ViewBag.FileId"; />

    @Html.LabelFor(model => model.comment.CreateDate, htmlAttributes: new { @class = "control-label col-md-2" })
    <input class="form-control text-box single-line" data-val="true" data-val-date="The field CreateDate must be a date." data-val-required="CreateDate 字段是必需的。" id="CreateDate" name="CreateDate" type="datetime" value="@DateTime.Now.ToString()"; />

    @Html.LabelFor(model => model.comment.UserId, htmlAttributes: new { @class = "control-label col-md-2" })
    <input class="form-control text-box single-line" id="UserId" name="UserId" type="text" value="@User.Identity.Name.ToString()"; />

    @Html.Validati onMessageFor(model => model.comment.UserId, "", new { @class = "text-danger" })
    @Html.LabelFor(model => model.comment.review, htmlAttributes: new { @class = "control-label col-md-2" })
    @Html.EditorFor(model => model.comment.review, new { htmlAttributes = new { @class = "form-control" } })
    <input type="submit" value="Create" class="btn btn-default" />
    }
    </div>
    <div id="loading" style="display:none">
    <p>正在提交服务器。。。</p>
    </div>
    1 条回复    2016-05-17 10:41:08 +08:00
    CBBing
        1
    CBBing  
    OP
       2016-05-17 10:41:08 +08:00



    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   884 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 21:45 · PVG 05:45 · LAX 13:45 · JFK 16:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.