Search code examples
asp.netvb.netmeta

How to change metatags dynamically?


I am working on a site where the meta tags are set in a Masterpage in a section using runat="server". I can update the title, description, keywords, etc... through properties in the Masterpage code-behind, but how would I add or edit non-basic ones such as

I have tried the following, but it always returns 0 for the count.

   Dim header As Web.UI.HtmlControls.HtmlHead
            header = TryCast(Me.Master.FindControl("headerIdName"), Web.UI.HtmlControls.HtmlHead)
            Dim count As Integer = header.Controls.Count

Solution

  • You have to iterate through the controls in the header:

    How do I retrieve a custom meta tag in a page?