简体   繁体   中英

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 ;";

在将其发送到您的页面之前使用HTML编码。

This this

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

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM