开发者

Display meta tag content as a string on webpage

I have the following code:

lblMetaTag.Text = 
   "<meta property='" + ctrl.property_name + 
       "' content='" + ctrl.property_value + "' />";

When it renders to the page - it renders the meta tag and not开发者_开发问答 the string representation.

How do I display it as the string?


Change it to the following:

lblMetaTag.Text = 
   "&lt ;meta property='" + ctrl.property_name + "' content='" + 
    ctrl.property_value + "' /&gt ;";


Use HTML encoding before sending putting it on your page.


This this

lblMetaTag.Text = Server.HtmlEncode(
        "<meta property='" + ctrl.property_name + 
        "' content='" + ctrl.property_value + "' />");

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜