在asp net mvc视图中更新textarea内容tinymce

时间:2015-11-24 13:20:43

标签: javascript c# asp.net asp.net-mvc tinymce

控制器

[HttpPost]
public ActionResult Edit(ExampleClass model)
{
    if (ModelState.IsValid)
    {
        try{
            model.WriteToDocFile(model.HtmlContent, byteLimit);                  
            TempData["message"] = "File has been successfully saved.";
        } catch {
            TempData["message"] = "Cant save file. Have some trouble with system.";
        }
    } else {
        TempData["message"] = "Cant save file. Have some trouble with model.";
    }            
    return View(model);
}

查看其中显示tinymce编辑器

@using (Html.BeginForm("Edit", "Editor"))
{
    <button id="saveDocBtn" type="submit" class="btn btn-lg" style="background-color:green;" data-toggle="tooltip" title="Save boxdoc">
        <span class="glyphicon glyphicon-ok-sign"></span>
    </button>
    @Html.AntiForgeryToken()
    @Html.HiddenFor(o => o.PathToFile)
    @Html.HiddenFor(o => o.DocTitle, new { id="docName"})
    <div>
        <!-- This will contain your HtmlContent and use the TinyMCE editor-->            
        @Html.TextAreaFor(o => o.HtmlContent, new { rows = 17, id = "tinyTextArea"})
    </div>
}
问题是,如果输入文本的大小超过某个预定值,我需要将其剪切并保存。保存并将模型发送到视图后,数据将采用所需的格式(必要时剪切),但在文本编辑器中显示完整版本。如何实现有效数据到textarea的映射?

0 个答案:

没有答案