在网页中显示html代码

string str = "<div>aaa</div>";
            this.Literal1.Text = string.Format("<pre>{0}</pre>", str.Replace("<", "&lt;").Replace(">", "&gt;"));

 

string str = "<div>中国</div>";
            this.Literal1.Text = Server.HtmlEncode(str);

 

posted @ 2014-08-10 13:07  冰封的心  阅读(406)  评论(0编辑  收藏  举报