我想实现微小MCE文本编辑器来我的创建页。我使用 [AllowHtml] 属性到我的机身属性,但它仍然无法正常工作。我的博客详细视图仍呈现HTML标签。
I'm trying to implement Tiny MCE text editor to my Create page. I've used [AllowHtml] attribute to my Body property but it still doesn't work. My detail view for the blog still showing html tags.
这是我的博客实体类。
public class Blog { public int Id { get; set; } [Required] public string Title { get; set; } [AllowHtml] [Required] [DisplayName("Content")] public string Body { get; set; } [DisplayName("Created on")] [DataType(DataType.Date)] [Required] public DateTime Created { get; set; } }
PIC的下方显示了我创建的博客页面(这节目我有TinyMCE的实现的属性和工作)
The pic below shows my create blog page (which shows that I have TinyMCE implemented property and working)
这下面的图片显示我的详细信息页面的博客。这里的问题是,它展示的剧照,尽管我已经允许HTML到我的机身属性HTML标签。
This pic below shows my detail page for a blog. The problem here is that it stills showing html tags even though I've allowed html to my Body property.
推荐答案AllowHtml属性只是模型绑定,通过不验证(白名单的HTML标记)对HTML标签帮助。它没有做任何事情与UI。
AllowHtml attribute just helps with model binding , by not validating(white listing html tags) against html tags . It does not do any thing with UI.
要显示的文本值,而不是HTML编码,你可以使用 @ Html.Raw(型号.property)
To display the text value and not html encode it, you can use @Html.Raw(Model.property)
更多推荐
AllowHtml属性不起作用
发布评论