1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Populate Head Content

Populate Head Content

2 posts, 0 answered
  1. Chris Wilper
    Chris Wilper avatar
    13 posts
    Registered:
    01 Sep 2009
    19 Oct 2009
    Link to this post
    How can I populate the Head Content of a page with code.  I need to update the Title, Description, and Keywords based on a querystring value that is passed in.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    20 Oct 2009
    Link to this post
    Hello Chris Wilper,

    There are two options that you can use

    1. Create a control that gets the current page and then set the page meta head tags.

    ICmsUrlContext pageID = (ICmsUrlContext)this.Context.Items[UrlHelper.CmsPageKey];
    Guid pID = new Guid(pageID);
    var manager = new CmsManager();
    ICmsPage cmsPage = (ICmsPage)manager.GetPage(pID, true);
    cmsPage.Title = "some title";
    cmsPage.Description = "some descr";
    cmsPage.Keywords = "some keys";
    manager.SavePage(cmsPage);

    2. Using standard .NET class - HtmlMeta

    HtmlMeta meta = new HtmlMeta();
    meta.Name = "keywords";
    meta.Content = "some key workds";
    this.Header.Controls.Add(meta);

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered