I have a website with a bunch of pages. I have 4 master pages that all of the pages use. Each page uses different css and JavaScript includes inside of the head tags. I would like to add the title, meta description, and meta keywords tags in through a call to a class that will reference a database table. However, I cannot figure out a way to pass the page or an HthmlHead object into the class without it throwing an error. I have tried doing
HtmlHead head = Page.Header;
Page.Controls.Remove(Page.FindControl("HeadElement"));
Page.FindControl("HtmlElement").Controls.AddAt(0,HeaderText.getHeaderText(head, Request.Url.AbsolutePath));
and
Page = p2
Page = HeaderText.getHeaderText(p2, Request.Url.AbsolutePath));
In both cases I changed my class HeaderText.getHeaderText to return the page or HtmlHead types depending on what I was doing. I setup the class to look like this:
public class HeaderText
{
private HeaderText() { }
public static HtmlHead getHeaderText(HtmlHead head, String URL)
Is there a better or easier way to do this?