ASP.NET MVC 2 Telerik编辑器不显示格式化的文本

| 我在Telerik MVC编辑器控件上遇到问题,该控件允许我输入数据,正确格式化(粗体等)并将其保存到数据库。当我在浏览器中查看数据时,它会按预期显示(在所有浏览器中)。 当我尝试在编辑器中再次编辑文本时,它无法正确显示格式,而是显示围绕文本的HTML标签,即与格式化文本相反。 当我第二次将数据保存到数据库并再次查看时,数据将以以下格式显示:工作描述 这是我用来显示文本编辑器的代码:
<% Html.Telerik().Editor()
    .Name(\"Description\")
    .Value(Model.Description)
    .Render();
%>

// Code to the populate the model before saving to the database: There is no endcode or decode instruction here
article.Description = collection[\"Description\"];
// Save changes.
要在浏览器中显示代码,请使用以下代码:
<%=
    HttpUtility.HtmlDecode(Model.Description)
%>
希望这种解释是有意义的,并且有人可以帮助阐明这一点?我真的很困惑如何使它正常工作。     
已邀请:
我正在使用带有Telrik控件的ASP.NET MVC 3,并且使用了下面的代码,并且工作正常。 对于创建编辑器-在视图页面中
 @{ Html.BeginForm(); }
            @Html.Telerik().EditorFor(model => model.Body).HtmlAttributes(new { style = \"height:200px; width:500px;\" })
            @Html.ValidationMessageFor(model => model.Body)

@{ Html.EndForm(); }
在控制器中
 public ViewResult Details(int id)
        {
            ArticleModels articlemodels = db.ArticleModels.Find(id);
            articlemodels.Body = HttpUtility.HtmlDecode(articlemodels.Body);
            return View(articlemodels);
        }
用于在视图中编辑
@Html.Telerik().EditorFor(model => model.Body).HtmlAttributes(new { style = \"height:200px; width:500px;\" })
    
我让它为我工作,希望它能为您工作。 在我看来,我使用以下代码:
<%: Html.Telerik().EditorFor(model => model.Description).Name(\"ContentEditor\")%>
然后在控制器中,将值传递到模型外部(因为Model.Description属性始终为null,所以我不知道为什么),如下所示:
[HttpPost]
public ActionResult Detail(MyModel myModel, string contentEditor)
{
    myModel.Description = HttpUtility.HtmlDecode(contentEditor);
    // Do stuff & save to DB
}
    

要回复问题请先登录注册