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

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

  •  1
     
  •   CBBing · 2016-05-17 10:32:00 +08:00 · 1901 次点击
    这是一个创建于 3120 天前的主题,其中的信息可能已经有所发展或是发生改变。
    @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   ·   实用小工具   ·   2864 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 12:16 · PVG 20:16 · LAX 04:16 · JFK 07:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.