More in this section
Forums / Developing with Sitefinity / How to retrieve News GUID in detail page?

How to retrieve News GUID in detail page?

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
2 posts, 0 answered
  1. MJia
    MJia avatar
    44 posts
    09 Jun 2009
    03 Jun 2010
    Link to this post
    I have set up a newslist / detail page and it works fine.
    I need to change the layout of the detail page so I specify a new ascx page for the new layout: /Sitefinity/ControlTemplates/News/styled_ListPageDetails_modified.ascx

    My question is how can I display / or retrieve the GUID of the news that is displaying?

    The url is like this format: [Publication_Date]/[Title].aspx, which is perferred, I don't want the GUID to be part of the url.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    03 Jun 2010
    Link to this post
    Hello MJia,

    The code below will return the ID of the item that is being previewed

    Telerik.Cms.Engine.ContentManager Manager = new Telerik.Cms.Engine.ContentManager("News");
    if (Context.Items.Contains(Manager.Provider.ContentItemKey))
        var itemId = (Guid)((Telerik.Web.IUrlRewriteData)Context.Items[Manager.Provider.ContentItemKey]).Data;
     IConent cntObject = Manager.GetContent(itemId);
       if(cntObject !=null)
         string TitleKey = (string)cntObject.GetMetaData("Title");

    The url format can be changed from the web.config, providers declaration under cmsEngine node. There is a property urlRewriteFormat

    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
2 posts, 0 answered