Asp.net mvc 将ContentBuilder.js与.NET MVC结合使用
我正在尝试将contentbuilder.js集成到.NET MVC应用程序中 我可以让页面加载,但我一直在思考如何提取已编辑的HTML以保存它 Innova似乎没有提供任何集成演示。任何见解都会非常有用Asp.net mvc 将ContentBuilder.js与.NET MVC结合使用,asp.net-mvc,Asp.net Mvc,我正在尝试将contentbuilder.js集成到.NET MVC应用程序中 我可以让页面加载,但我一直在思考如何提取已编辑的HTML以保存它 Innova似乎没有提供任何集成演示。任何见解都会非常有用 谢谢。我终于明白了。为其他使用ContentBuilder、c#和MVC的用户发布 接收数据的模型需要具有[AllowHtml]属性: public class HtmlModel { public int ID { get; set; } [
谢谢。我终于明白了。为其他使用ContentBuilder、c#和MVC的用户发布 接收数据的模型需要具有[AllowHtml]属性:
public class HtmlModel
{
public int ID { get; set; }
[AllowHtml]
public string Html { get; set; }
}
SubmitJavaScript需要在jquery和validate之间切换——您可以在布局页面中使用下面的标记,以允许将视图页面上的脚本内容放置在那里
@RenderSection("scripts", required: false)
HTML页面:
@model MVCTutorial.Models.EmployeeViewModel
@section Scripts
{
<script>
$(document).ready(function () {
$("#btnSubmit").click(function () {
debugger
var builder = new ContentBuilder({
container: '.container',
});
var html = builder.html(document.querySelector('#cmshtml')); //Get 1st area content
var data = $("#myForm").serialize() + '&Html=' + builder.html(document.querySelector('#cmshtml'));
$.ajax({
type: "POST",
url: "/HtmlHelper/Index",
data: data,
success: function (response) {
alert("you are done");
}
})
})
})
</script>
}
<div class="container" style="width:40%; margin-top:2%">
<div id="cmshtml">
<p>hello world!</p>
</div>
<form id="myForm">
@Html.TextBoxFor(model => model.PageName, new { @class = "form-control", @placeholder = "name" })
<input type="button" value="Submit" class="btn btn-block btn-primary " id="btnSubmit" />
</form>
</div>
[HttpPost]
public ActionResult Index(CMSmodel model)
{
string html = model.Html;
string Name = model.Name;
///perform tasks here
return View();
}