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

2016-05-17 10:32:00 +08:00
 CBBing
@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.ValidationMessageFor(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>
1877 次点击
所在节点    问与答
1 条回复
CBBing
2016-05-17 10:41:08 +08:00



这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/279146

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX