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

Forums / Developing with Sitefinity / How to display MetaData in PreviewMode?

How to display MetaData in PreviewMode?

3 posts, 1 answered
  1. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    25 Mar 2010
    Link to this post
    Hi there,

    I'm working on a module that's closely based on the sample Products Module. In the project there's a user control that is a template at /Resources/ControlTemplates/Backend/ProductPreviewView.ascx  This control has a repeater (repeaterItemMetaData) that automatically lists all meta data. This is ok, but what I'd really like to do is display a couple meta data fields outside of this repeater.

    My question is, where do I override page_load (assuming that's what I want to do) and how do I access the metadata and assign it to a control (i.e. a literal) that's in the usercontrol. I assume I'd probably want to add it to /WebControls/Admin/Products/ProductPreviewView.cs but I can't seem to get it to work.

    Any suggestions would be greatly appreciated!

    Cheers,
    Phill
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    25 Mar 2010
    Link to this post
    Hello Phill Hodgkinson,

    You could get the content ID from the QueryString,

    ProductsPreviewView itemPreview = (ProductsPreviewView)this.Parent.Parent;
    Guid contentID = new Guid(CmsHttpRequest.Current.QueryStirng[itemPreview.ParameterKey]);
    IContent content = itemPreview.Manager.GetContent(contentID);

    or calling this.DataItemId

    In ProductsPreviewView class you could override InitilalizeControls and set the custom value

    protected override void InitializeControls(System.Web.UI.Control viewContainer)
    {
        base.InitializeControls(viewContainer);
     
        this.customListeral.Text = "sss";
    }
     
    protected virtual Literal customListeral
    {
        get
        {
            return this.Container.GetControl<Literal>("Literal1", false);
        }
    }


    Best wishes,
    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.
    Answered
  3. Phill Hodgkinson
    Phill Hodgkinson avatar
    362 posts
    Registered:
    10 Nov 2004
    25 Mar 2010
    Link to this post
    As always, Telerik Support (Ivan) comes through again!

    Many thanks, just what I was looking for!

    Cheers,
    Phill
Register for webinar
3 posts, 1 answered