我在asp.net core mvc
中对CKEDTOR4有问题。它将null
返回给控制器。这是我的代码。你能帮我吗?
控制器:
public IActionResult AddProducts(Products product, IFormFileUploadImage,string CommentText)
{
ProductRepository blProduct = new ProductRepository();
string webRootPath = _hostingEnvironment.WebRootPath;
//var temp = formValues["Product.Summery"];
string contentRootPath = _hostingEnvironment.ContentRootPath;
product.Image = UploadImage.FileName;
string path = webRootPath + "\\Files\\UploadImages\\ax.jpg";
UploadImage.OpenReadStream().ResizeImageByWidth(500, path, Utilty.ImageComperssion.Normal);
if (blProduct.Add(product))
{
ModelState.AddModelError("Error", "success");
}
else
{
ModelState.AddModelError("Error", "Fail");
}
return View();
}
}
视图:
<div class="form-group">
<label asp-for="Product.Summery" class="control-label"></label>
<div class="controls">
<textarea asp-for="Product.Summery" class="ckeditor" id="editor1"></textarea>
<span asp-validation-for="Product.Summery" class="text-danger"></span>
</div>
</div>
<script type="text/javascript">
CKEDITOR.replace('Product.Summery');
</script>
<script src="@Url.Content("~/ckeditor/ckeditor.js")"></script>