HTML:
<meta name="description" runat="server" id="MetaDescription" content="" />
Codebehind:
MetaDescription.Attributes["content"] = ThisBlog.MetaDescription;
This renders as:
<meta id="HeadContent_MetaDescription" name="description" content="My page description"></meta>
As per this answer it needs to have no ID attribute, and close with />
.
How can I make it render in this way?
I am still on .net 3.5 but put this in Page_Load and it will do what you need:
PS: the example is for the keywords tag but the result is the same.
You should remove the
id
property from the<meta>
, this means the control won't be accessible from the server side byid
but instead of it it could be dynamically created and then added to the page: