我在使用 Telerik MVC 编辑器控件时遇到问题,它允许我输入数据、正确格式化(粗体等)并将其保存到数据库中。当我在浏览器中查看数据时,它会按预期显示(在所有浏览器中)。
当我尝试在编辑器中再次编辑文本时,它不会正确显示格式,而是显示文本周围的 HTML 标签,即与格式化文本工作相反。
当我第二次将数据保存到数据库并再次查看时,数据以这种格式显示:<strong>工作描述</strong>
这是我用来显示文本编辑器的代码:
<% 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)
%>
希望这个解释是有道理的,有人可以帮助阐明这一点吗?我真的很困惑如何使它正常工作。