I have included js files and able to see the control on the browser.
我已经包含了js文件,并且能够在浏览器上看到控件。
Could you please anybody explain how to use Aloha editor in Asp.net MVC framework, I strucked at getting the value from Editor control and post to data base.
你能不能解释一下如何在Asp.net MVC框架中使用Aloha编辑器,我试图从编辑器控件获取值并发布到数据库。
Thanks, Bhaskar
谢谢,巴斯卡尔
1 个解决方案
#1
1
Here is a simple example of how to save content from aloha editor using .Net MVC.
这是一个如何使用.Net MVC从aloha编辑器保存内容的简单示例。
This should be enough to get you started.
这应该足以让你入门。
Add a button to save the content on the same page as Aloha editor
添加一个按钮以将内容保存在与Aloha编辑器相同的页面上
<input type="button" id="save-content" value="save"/>
Create a controller action to save your content.
创建控制器操作以保存您的内容。
public ActionResult SaveContent(string editor, string content)
{
//save content to db here
return Json(new {success = true}, JsonRequestBehavior.AllowGet);
}
Then add the following script to the page. This will loop through any aloha editors on your page, and make an ajax request to save the content using the controller action you just created.
然后将以下脚本添加到页面。这将遍历页面上的任何aloha编辑器,并使用刚创建的控制器操作发出ajax请求以保存内容。
<script>
$('#save-content').on('click', function() {
jQuery.each(Aloha.editables, function(index, editable) {
$.ajax({
url: @Url.Action("SaveContent"),
type: 'post',
data: {editor: editable.getId(), content: editable.getContents()}
}).done(function(){
alert('content saved');
});
});
});
</script>
#1
1
Here is a simple example of how to save content from aloha editor using .Net MVC.
这是一个如何使用.Net MVC从aloha编辑器保存内容的简单示例。
This should be enough to get you started.
这应该足以让你入门。
Add a button to save the content on the same page as Aloha editor
添加一个按钮以将内容保存在与Aloha编辑器相同的页面上
<input type="button" id="save-content" value="save"/>
Create a controller action to save your content.
创建控制器操作以保存您的内容。
public ActionResult SaveContent(string editor, string content)
{
//save content to db here
return Json(new {success = true}, JsonRequestBehavior.AllowGet);
}
Then add the following script to the page. This will loop through any aloha editors on your page, and make an ajax request to save the content using the controller action you just created.
然后将以下脚本添加到页面。这将遍历页面上的任何aloha编辑器,并使用刚创建的控制器操作发出ajax请求以保存内容。
<script>
$('#save-content').on('click', function() {
jQuery.each(Aloha.editables, function(index, editable) {
$.ajax({
url: @Url.Action("SaveContent"),
type: 'post',
data: {editor: editable.getId(), content: editable.getContents()}
}).done(function(){
alert('content saved');
});
});
});
</script>