Hi,
For one of my static pages I need to dynamically change the meta description from the CodeBehind file (myPage.aspx.cs)
I did some research and found that the way to do this in .NET 3.5 is:
Code:protected void Page_Load(object sender, System.EventArgs e) { <..other existing code..> //set meta tag description HtmlMeta hm1 = new HtmlMeta(); hm1.Name = "description"; hm1.Content = "Test Description"; Page.Header.Controls.Add(hm1); }
However, instead of modifying the existing tag, it creates a duplicate <meta name="description" content=""> just before the </header> tag with content being populated from ASPDNSF. The description I am inputting in the hm1.Content is ignored.
This only works if I delete the <meta name="description" content=""> tag from my template.master. With the meta tag deleted from the template everything works fine.
But since other pages need to pull the description from ASPDNSF I cannot just simply delete the meta tag in template.master.
I have also tried putting an if statement in the template.master file to detect the filename and only write the meta tag if the page is not myPage.aspx but I received an error saying that code blocks are not allowed in that section.
How can I edit the description in the aspx.cs file?
Thanks in advance,