繁体   English   中英

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

[英]Display meta tag content as a string on webpage

我有以下代码:

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

当它呈现给页面时 - 它呈现元标记而不是字符串表示。

如何将其显示为字符串?

将其更改为以下内容:

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

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

这个

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

希望这可以帮助。

暂无
暂无

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

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