What I want to do is export the data from RTE to the database and import it into RTE when I need it in the same format.
How can I achieve this ?
$("#saveData").click(function () {
$.ajax({
url: '@Url.Action("SaveRTEdata")',
data: {
'msg': $("#rteMsg").data("ejRTE").getHtml()
},
type: "POST",
success: function (result) { },
error: function (result) { }
});
})
Regards,
Anis
|
<httpRuntime targetFramework="4.5" requestValidationMode="2.0" />
<pages validateRequest="false"> |
|
[HttpPost,ValidateInput(false)]
public ActionResult SaveRTEdata()
{
var value=Request.Form["msg"];
return View("RichTextEditorFeatures");
} |
|
<div>
@{Html.EJ().RTE("rteSample").ContentTemplate(@<p>
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
</p>).ClientSideEvents(e=> e.Create("onCreate")).Render();}
</div>
<br /><br />
<button id="btn" >Import content from Server</button>
<script>
var rteObj;
$(function () {
$("#btn").on("click", function () {
$.ajax({
url: "@Url.Action("GetData", "Home")",
type: "GET",
contentType: "application/json; charset=utf-8",
success: function (e) {
rteObj.setHtml(e); //setting Html content for RTE
}
});
});
});
function onCreate() {
rteObj = this; // accessing control’s instance
}
</script> |
|
public ActionResult GetData()
{
var NewContent = "<p>This is <b>New</b> content from the <i>Controller</i></p>";
return Content(NewContent);
} |