C#ASP.net渲染HTML字符串 [英] C# ASP.net render HTML String

查看:247
本文介绍了C#ASP.net渲染HTML字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个位code在我类似这样的标记:

I have a bit of code in my markup like this :

<% Response.Write(((String)objRow["Post"]).Trim()); %>

在的objRow [邮报]的值为HTML标记 - 类似这样的:

The value in objRow["Post"] is HTML markup - similar to this:

<p><span style="color: #ff0000;">asdsada</span></p>

其中的内容物使用TinyMCE的创建。我现在要呈现结果HTML - 基本保存功能pviously创造了$ P $的视图功能

The content of which was created using tinymce. I now want to render the resultant html - basically a view function of a previously created save function.

目前,我的标记从字面上吐出你看到没有到我的网站的HTML - 但我真正想要的是短信说asdsada的红线

At the moment, my markup literally spits out the HTML you see there onto my website - but what I really want is a red line of text saying asdsada.

请帮忙

推荐答案

这听起来像你试图显示值已经是HTML EN codeD。试试这个:

it sounds like the value you are trying to display is already html encoded. try this:

<%= HttpUtility.HtmlDecode((string)objRow["Post"]) %>

这篇关于C#ASP.net渲染HTML字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆