///
/// Renders page meta tag
///
/// Page instance/// Meta name/// Content/// Overwrite existing content if existspublic static void RenderMetaTag(Page page, string name, string content, bool OverwriteExisting)
{
if (page == null || page.Header == null)
return;
foreach (Control control in page.Header.Controls)
if (control is HtmlMeta)
{
HtmlMeta meta = (HtmlMeta)control;
if (meta.Name.ToLower().Equals(name.ToLower()) && !string.IsNullOrEmpty(content))
{
if (OverwriteExisting)
meta.Content = content;
else
{
if (String.IsNullOrEmpty(meta.Content))
meta.Content = content;
}
}
}
}
///
/// Renders page title
///
/// Page instance/// Page title/// Overwrite existing content if existspublic static void RenderTitle(Page page, string title, bool OverwriteExisting)
{
if (page == null || page.Header == null)
return;
if (String.IsNullOrEmpty(title))
return;
if (OverwriteExisting)
page.Title = title;
else
{
if (String.IsNullOrEmpty(page.Title))
page.Title = title;
}
}
You can load data from Database.
Comments
No responses to “Create HTML Meta tag and Title Website.”
Post a Comment