This topic provides a way to add meta tags to a page.
When there is information that needs to be added to a page and displayed, a possible solution is to add it as a meta tag on the page. The following user
control provides the opportunity to add the information on every Sitefinity page:
| .ascx.cs |
Copy Code |
|
public partial class Sitefinity_UserControls_MetaTagsControl : System.Web.UI.UserControl
{
#region Public Properties
public string MetaTagName
{
get
{
return metaTagName;
}
set
{
metaTagName = value;
}
}
public string MetaTagContent
{
get
{
return metaTagContent;
}
set
{
metaTagContent = value;
}
}
#endregion
protected void Page_Load(object sender, EventArgs e)
{
HtmlMeta metaTag = new HtmlMeta();
metaTag.Name = this.MetaTagName;
metaTag.Content = this.MetaTagContent;
this.Page.Header.Controls.Add(metaTag);
}
private string metaTagName;
private string metaTagContent;
}
|
In order to use it as a public control and be able to add it to a Sitefinity page, this user control should be uploaded in the toolbox.