简体   繁体   English

在网页上将元标记内容显示为字符串

[英]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. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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