how can i add title and meta tags for content pages in a project base on master and content page(dinamically) ?
i used the blow method for master page :
public void SetMetaTags(string title, string description, string keywords)
{
// Get a reference to the HTML Head
HtmlHead headTag = (HtmlHead)Page.Header;
// Set the page title
headTag.Title = title;
// Add a Description meta tag
HtmlMeta metaTag = new HtmlMeta();
metaTag.Name = "Description";
metaTag.Content = description;
headTag.Controls.Add(metaTag);
// Add a Keywords meta tag
metaTag = new HtmlMeta();
metaTag.Name = "Keywords";
metaTag.Content = keywords;
headTag.Controls.Add(metaTag);
}
so i don't know why the blow code in page_Load Of Content Page Have An Error :
protected void Page_Load(object sender, EventArgs e)
{
MasterPage MyMasterPage = (MasterPage)Master;
MyMasterPage.SetMetaTags("Title", "description", "keywords"); *
}
and the error is :(in line *)
Error 17 'System.Web.UI.MasterPage' does not contain a definition for 'SetMetaTags' and no extension method 'SetMetaTags' accepting a first argument of type 'System.Web.UI.MasterPage' could be found (are you missing a using directive or an assembly reference?) C:\Javad---\AlmasAfzar\AlmasAfzar\AlmasAfzar\Products.aspx.cs 16 26 AlmasAfzar
thanks in future advance
best regards