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 =
"< ;meta property='" + ctrl.property_name + "' content='" +
ctrl.property_value + "' /> ;";
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.
精彩评论