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

Forums / Developing with Sitefinity / Embed templates in control designers

Embed templates in control designers

6 posts, 0 answered
  1. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    28 Sep 2010
    Link to this post
    Hi,

    I've developed a control designer that references a template with:

    public override string LayoutTemplatePath {
    get { return "~/lib/controls/genericContent/backend/featureBox.ascx"; }
    }

    I would like to embed this as a resource instead. How do i acheieve thjis?

    Thanks
    higgsy
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Sep 2010
    Link to this post
    Hello Alastair,

    You can take a look at this post.

    Greetings,
    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
  3. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    28 Sep 2010
    Link to this post
    Hi Ivan,

    Thanks - slightly different sceanrio.

    My usercontrol is part of a module. 

    I have :

    namespace dotcentric.SiteFinity.Web.UI.Public.WebControls.CaseStudy {
     
        public class CaseStudyFeaturedItem : CaseStudySelectorControlDesignerBase {
     
    }
     
    }

    Which i need to reference to my usercontrol markup. In the example of a SimpleControl i used:

    #region Fields
     
    private const string StudyViewSingleItemTemplateName = "dotcentric.Resources.ControlTemplates.FrontEnd.CaseStudy.CaseStudySingleItemView.ascx";
     
    #endregion
     
    #region Properties
     
    [Browsable(false)]
    [WebSysTemplate(CaseStudySingleItemView.StudyViewSingleItemTemplateName, "StudyView_SingleItemTemplate_Descs", "/CaseStudy", true, "2009-02-17")]
    public override string LayoutTemplatePath {
        get {
            return base.LayoutTemplatePath;
        }
        set {
            base.LayoutTemplatePath = value;
        }
    }
     
    /// <summary>
    /// Define Template for custom control
    /// </summary>
    public override string LayoutTemplateName {
        get {
            return StudyViewSingleItemTemplateName;
        }
    }

    But that doesnt seem to work when i am inheriting from my control designer base.

    higgsy
  4. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    28 Sep 2010
    Link to this post
    To clarify my last post.

    I've developed a control designer.

    I have a class called CaseStudyFeaturedItem which inherits from my ControlDesignerBase (which itself inherits from System.Web.Ui.UserControl).

    My class CaseStudyFeaturedItem needs a template, but i cant figure out how to use my constant which references an embedded template.

    private const string CaseStudySelectorPublicTemplate = "dotcentric.Resources.ControlTemplates.FrontEnd.CaseStudy.FeaturedCaseStudy.ascx";

    CaseStudyFeaturedItem doesnt have properties for LayoutTemplatePath or LayoutTemplateName which is what ive previously used.

    Any thoughts?

    Thanks in advance
    higgsy

  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Sep 2010
    Link to this post
    Hi Alastair,

    You need a template and container. You can take a look at How to: Create Templated ASP.NET User Controls

    All the best,
    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
  6. higgsy
    higgsy avatar
    336 posts
    Registered:
    05 Aug 2010
    28 Sep 2010
    Link to this post
    REally? I thought there was an easier way that was used frequently from within SiteFinity....similar to how you can call a template from a UITypeEditor???

    private ITemplate _strTemplate;

    public string Template {
    get {
    object o = this.ViewState["Template"];
    if (o == null)
    return ("~/lib/controls/MultipleImageSelector.ascx");
    return (string)o;
    }
    set {
    this.ViewState["Template"] = value;
    }
    }

    this._strTemplate = ControlUtils.GetTemplate<SelectorTemplate>(this.Template);
    this._strTemplate.InstantiateIn(this);

    public class SelectorTemplate : ITemplate {
    public void InstantiateIn(Control container) {
    }
    }

    Would something similar not work???
Register for webinar
6 posts, 0 answered