如何在HTML中呈现代码 [英] How to render code in html

查看:115
本文介绍了如何在HTML中呈现代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

如何使标签控制代码呈现为以代码格式而不是控制格式显示.

例如,以标签控制为例,我希望这样的输出
< asp:label ID ="lbl" runat ="server"/>

作为参考,stacoverflow以及在codeproject中的aspx控件都以所有格式显示为文本,而不是显示控件.

Hello,

How to render label control code to display in code format instead of control format.

E.g- let take an example of label control i want my output like this
<asp:label ID="lbl" runat="server" />

As a reference stacoverflow and also in codeproject aspx control display as a text with all formatting rather then displaying control.

推荐答案

您需要使用HttpServerUtility类对该HTML进行编码.请参考- HttpServerUtility.HtmlEncode [ ^ ].
You need to encode this HTML with HttpServerUtility class. Refer - HttpServerUtility.HtmlEncode[^].


这篇关于如何在HTML中呈现代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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