AllowHtml属性不起作用

编程入门 行业动态 更新时间:2024-10-19 16:39:23
本文介绍了AllowHtml属性不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想实现微小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属性不起作用

本文发布于:2023-11-11 23:00:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1579788.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   属性   AllowHtml

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!