提问人:Zahid Lateef 提问时间:8/16/2023 最后编辑:marc_sZahid Lateef 更新时间:8/16/2023 访问量:21
CkEditor textarea 在控制器 POST 方法中始终返回 null?ASP.NET MVC
CkEditor textarea return always null in controller POST method? ASP.NET MVC
问:
我已经在我的 asp.net mvc 项目中进行了配置。它显示良好,但它始终在控制器方法中返回值。CKEditor
null
HttpPost
控制器:
[ValidateInput(false)]
[Authorize]
[HttpPost]
public ActionResult CreateActor([Bind(Include = "ActorId,Name,AlternateName,BirthDate,Height,ImageUrl,Executive")] Actor actor)
{
if (ModelState.IsValid)
{
db.Actors.Add(actor);
db.SaveChanges();
return RedirectToAction("LoadActors");
}
return View(actor);
}
视图:
@model MA2231A5.Data.Actor
@{
ViewBag.Title = "Create Actor";
Layout = "~/Views/Shared/_Layout.cshtml";
<script src="https://cdn.ckeditor.com/ckeditor5/38.1.0/classic/ckeditor.js"></script>
}
<style>
.ck-editor__editable_inline {
min-height: 125px;
}
</style>
<h2>Create Actor</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<div class="form-group">
@Html.LabelFor(model => model.Biography, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Biography, new { htmlAttributes = new { @class = "ckeditor" } })
@Html.ValidationMessageFor(model => model.Biography, "", new { @class = "text-danger" })
<script type="text/javascript">ClassicEditor.CKEDITOR('Biography');</script>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}
<script>
ClassicEditor
.create(document.querySelector("#Biography"))
.catch(error => {
console.error(error);
});
</script>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
答: 暂无答案
评论