Rewriting meta tags and title on the fly
I was setting Page.Header.InnerHtml to update meta tags/desc on the fly, but this was making it so I had to also set the style sheet and anything else in the header again (since it was erasing the existing).
A way to get around this is to create literals and add them to the header:
LiteralControl metaTags = new LiteralControl();
LiteralControl metaDesc = new LiteralControl();
String strDesc ="A website";
String strTags ="website";
metaDesc.Text = "";
metaTags.Text = "";
Page.Header.Controls.Add(metaTags);
Page.Header.Controls.Add(metaDesc);
And I could already dynamically change the title by setting Page.Header.Title
A way to get around this is to create literals and add them to the header:
LiteralControl metaTags = new LiteralControl();
LiteralControl metaDesc = new LiteralControl();
String strDesc ="A website";
String strTags ="website";
metaDesc.Text = "";
metaTags.Text = "";
Page.Header.Controls.Add(metaTags);
Page.Header.Controls.Add(metaDesc);
And I could already dynamically change the title by setting Page.Header.Title

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home