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

Forums / Developing with Sitefinity / Accessing original Control properties from the Custom Control.

Accessing original Control properties from the Custom Control.

7 posts, 0 answered
  1. Che
    Che avatar
    6 posts
    Registered:
    21 Apr 2008
    14 Jan 2011
    Link to this post

    Hi!

    Sorry to bother on a big 4.0 opening day but I’m still using 3.7 and recently I have extended a NewsView control by adding a FilterExpression using a custom control.  Now while selecting “Edit” I’m getting properties tab of a custom control only. Is there a way to expose original control properties which were available in both basic and advanced tabs defined in external templates for this and all other Content View controls like ImageGallery, ContentView, Video etc. ?

    Thank you and a Happy New Year! (the Old Julian style… :-)

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Jan 2011
    Link to this post
    Hi Che,

    Add the following attribute to your custom control

    [ControlDesignerAttribute("Telerik.News.WebControls.Design.NewsViewDesigner, Telerik.News")]

    Actually you can inherit from NewsViewDesigner. You have to override DesignerTemplatePath and set the template path only.

    Kind regards,
    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. Che
    Che avatar
    6 posts
    Registered:
    21 Apr 2008
    20 Jan 2011
    Link to this post

    Hello Ivan,
    I’ve tried to follow your advice but getting no luck so far. Seems like just adding an attribute to the custom control is not enough as I’m getting following error:
    Unable to cast object of type 'ASP.usercontrols_controls_newsview_ascx' to type 'Telerik.Cms.Engine.WebControls.ContentView'.
    ..............................
    [InvalidCastException: Unable to cast object of type 'ASP.usercontrols_controls_newsview_ascx' to type 'Telerik.Cms.Engine.WebControls.ContentView'.]
       Telerik.Cms.Engine.WebControls.Design.ContentViewDesignerBase.InitializeComponent() +52
       Telerik.Cms.Engine.WebControls.Design.ContentViewDesignerBase.CreateChildControls() +20
       System.Web.UI.Control.EnsureChildControls() +102
       System.Web.UI.Control.PreRenderRecursiveInternal() +42
       System.Web.UI.Control.PreRenderRecursiveInternal() +175
    ........................................................

    and this is where I've added an attribute:

    [ControlDesignerAttribute("Telerik.News.WebControls.Design.NewsViewDesigner, Telerik.News")]
    public partial class Sitefinity_UserControls_ExtNewsView : System.Web.UI.UserControl, IUrlRewriterContainer
    {
      
          protected void Page_Load(object sender, EventArgs e)
        {
      
        }
      
        #region IUrlRewriterContainer Members
      
        public IUrlRewriterService GetUrlRewriterService()
        {
            return sfn_NewsViewExt.GetUrlRewriterService();
        }
      
        #endregion
    }

    Then trying to override DesignerTemplatePath I've placed into App_Code following module:

    namespace Telerik.Cms.Engine.WebControls.Design
    {
        public class NewsViewDesigner: ContentViewDesignerBase
        {
            public override string DesignerTemplatePath
            {
                get
                {
                    if (ViewState["DesignerTemplatePath"] == null)
                        return "~/Sitefinity/Admin/ControlTemplates/News/NewsViewControlDesigner.ascx";
                    return ViewState["DesignerTemplatePath"] as string;
                }
                set
                {
                    ViewState["DesignerTemplatePath"] = value;
                }
            }
        }
      
    }

    and didn't notice any effect at all...

    Then I've tried another approach - I mapped template directly in ListPageMaster.ascx:

    MasterTemplateName = "~\Sitefinity\ControlTemplates\News\ListPageMaster.ascx"

    and applied my filter there.
    For some reason while working with News template, being applied to the EventsViewControlDesigner.ascx:

    MasterTemplateName="~\Sitefinity\Admin\ControlTemplates\Events\Modes\ExpandableListMaster.ascx"

    it gives me this message:

    Invalid resource name (~\Sitefinity\Admin\ControlTemplates\Events\Modes\ExpandableListMaster.ascx) for assembly (Telerik.Events, Version=3.7.2136.340, Culture=neutral, PublicKeyToken=dfeaee0e3978ac79) or empty template.
    [ArgumentException: Invalid resource name (~\CoPanel\Admin\ControlTemplates\Events\Modes\ExpandableListMaster.ascx) for assembly (Telerik.Events, Version=3.7.2136.340, Culture=neutral, PublicKeyToken=dfeaee0e3978ac79) or empty template.]
    .............................................................
       Telerik.Framework.Web.ControlUtils.GetTemplate(String virtualPath, String resourceFileName, Type assemblyInfo, Type localizationAssemblyInfo) +927
       Telerik.Framework.Web.ControlUtils.GetTemplate(String virtualPath, String resourceFileName, Type assemblyInfo, Type localizationAssemblyInfo, Type templateMapType, String additionalTemplateKey) +326
       Telerik.Events.WebControls.EventsView.get_ItemListTemplate() +130
       Telerik.Cms.Engine.WebControls.ContentView.get_ListContainer() +50
       Telerik.Cms.Engine.WebControls.ContentView.CreateContentList() +23
       Telerik.Events.WebControls.EventsView.CreateContentList() +4
       Telerik.Cms.Engine.WebControls.ContentView.CreateChildControls() +4273
       Telerik.Events.WebControls.EventsView.CreateChildControls() +157
       System.Web.UI.Control.EnsureChildControls() +102
       System.Web.UI.Control.PreRenderRecursiveInternal() +42
       System.Web.UI.Control.PreRenderRecursiveInternal() +175
    ..........................................

    I'd appreciate if you can elaborate on your previous suggestions with more details and explain why I'm getting "Invalid resource name" after mapping templates which have several presentation modes i.e Events and ImageGallery.

    Thanks again,
    CHE.


  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    20 Jan 2011
    Link to this post
    Hello Che,

    1. You should have a custom control that inherits from NewsView
    2. The error

    Invalid resource name (~\Sitefinity\Admin\ControlTemplates\Events\Modes\ExpandableListMaster.ascx) for assembly (Telerik.Events, Version=3.7.2136.340, Culture=neutral, PublicKeyToken=dfeaee0e3978ac79) or empty template.

    This means that you are trying to set a template for a control of Telerik.Events assembly and this is not the custom control you have.

    Also you should not use back slashes

    MasterTemplateName="~\Sitefinity\Admin\ControlTemplates\Events\Modes\ExpandableListMaster.ascx"

    Kind regards,
    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
  5. Che
    Che avatar
    6 posts
    Registered:
    21 Apr 2008
    18 Feb 2011
    Link to this post

    Hi Ivan,

    I have the DesignerTemplatePath as well as both ItemListTemplatePath and 
    SingleItemTemplatePath overridden which allows me to set custom control
    properties via the original control, however
    only the Mode which is set in
    the TemplatePath is working properly when selected. Is there anything I
    can do resolve a problem?


    Thanks,
    Che.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    18 Feb 2011
    Link to this post
    Hi Che,

    1. From where you set the mode?
    2. What  is the behavior you see when you switch to anther more?


    Kind regards,
    Ivan Dimitrov
    the Telerik team
  7. Che
    Che avatar
    6 posts
    Registered:
    21 Apr 2008
    18 Feb 2011
    Link to this post
    Hi Ivan,
    1. Here is how I'm referencing templates:
    namespace Telerik.Libraries.WebControls
    {
        [ControlDesignerAttribute("Telerik.Libraries.WebControls.Design.ImageViewDesign, App_Code")]
        public class ImageViewControl : ImageGallery
        {
            public override string ItemListTemplatePath
            {
                get
                {
                    return "~/Sitefinity/ControlTemplates/Libraries/GalleryListView.ascx";
                }
                  
            }
            public override string SingleItemTemplatePath
            {
                get
                {
                    return "~/Sitefinity/ControlTemplates/Libraries/GalleryListViewItem.ascx";
                }
                  
            }
              
    ..............................................
      
      
    namespace Telerik.Libraries.WebControls.Design
    {
        public class ImageViewDesign : ImageGalleryDesigner
        {
            public override string DesignerTemplatePath
            {
                get 
                {  
                          return "~/Sitefinity/Admin/ControlTemplates/Libraries/ImageGalleryControlDesigner.ascx";  
                }  
            }
        }
    }
    ..............................

    2. If I select any other than a default mode, the single image will pop up just like it's '_self' hyperlinked .
    If I override ItemListTemplatePath  with i.e. "~/Sitefinity/Admin/ControlTemplates/Libraries/Modes/GalleryLightBoxList.ascx"  and select Lightbox in the Designer, it works properly, but if I select any other mode, the LightBox would start but image won't be opened.
    In case of other modules like Events, only default mode would start regardless to selection made in the Designer.

    Thanks for looking into the issue,
    Che. 
Register for webinar
7 posts, 0 answered