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

Forums / Developing with Sitefinity / Custom Control Panel - NullReferenceException BackendBreadcrumb

Custom Control Panel - NullReferenceException BackendBreadcrumb

2 posts, 0 answered
  1. Arend-Jan Kauffmann
    Arend-Jan Kauffmann avatar
    2 posts
    Registered:
    12 Jan 2010
    28 May 2010
    Link to this post
    Trying to create a custom controlpanel for a new service. Unfortunately I get the next error when I click on the service name in the Services commandpanel:

    Object reference not set to an instance of an object.

    Stack Trace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Telerik.Cms.Web.UI.Backend.BackendBreadcrumb.CreateChildControls() +39
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +44
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.AddedControl(Control control, Int32 index) +8682853
       System.Web.UI.ControlCollection.Add(Control child) +80
       Telerik.Cms.Web.UI.ServiceList.CreateChildControls() +1133
       System.Web.UI.Control.EnsureChildControls() +87
       System.Web.UI.Control.PreRenderRecursiveInternal() +44
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
    

    Background information:
    Versions
    Sitefinity: 3.7 SP3
    Telerik.Web.UI.dll / Telerik.Web.Design.dll: 2010.1.309.35

    Code:
    public class NAVService : WebModule, IService
    {
        public NAVService()
        {
        }
     
        #region WebModule Members
         
        public override Control CreateControlPanel(TemplateControl parent)
        {
            return new NAVServiceControlPanel();
        }
         
        public override IList<IToolboxItem> Controls
        {
            get { return null; }
        }
     
        public override string Description
        {
            get { return "This service can be used to access data from a Microsoft Dynamics NAV database using webservices"; }
        }
     
        public override string Name
        {
            get { return "NAV Service"; }
        }
     
        public override string Title
        {
            get { return "Microsoft Dynamics NAV data service"; }
        }
     
        #endregion
     
        #region IService Members
     
        public void Initialize()
        {
        }
     
        #endregion
    }

    public class NAVServiceControlPanel : ControlPanel<NAVServiceControlPanel>
    {
        public NAVServiceControlPanel()
        {
        }
     
        protected override void CreateViews()
        {
            AddView("Settings", "~/Custom/Services/NAVServiceControlPanel.ascx", "NAV Service Settings", "Specify how to connect to the NAV proxy service", "all", null);
        }
    }

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="NAVServiceControlPanel.ascx.cs" Inherits="Custom_Services_NAVServiceControlPanel" %>
    Control Panel

    What am I missing here?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    31 May 2010
    Link to this post
    Hi Arend-Jan Kauffmann,

    You should set the ControlPanel in your module - override CreateControlPanel. Your control panel class should inherit from ProviderControlPanel<Host>

    Module class

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik;
    using Telerik.Framework;
     
    /// <summary>
    /// Summary description for WebModule
    /// </summary>
    public class TestModule : WebModule, IService
    {
        public TestModule()
        {
        }
     
        #region IService Members
     
        public void Initialize()
        {
        }
     
        #endregion
     
        public override string Name
        {
            get { return "TestModule"; }
        }
     
        public override string Title
        {
            get { return "TestModule"; }
        }
     
        public override string Description
        {
            get { return "TestModule"; }
        }
     
        public override IList<Telerik.Web.IToolboxItem> Controls
        {
            get { return null; }
        }
     
        public override System.Web.UI.Control CreateControlPanel(System.Web.UI.TemplateControl parent)
        {
            return new TestModuleControlPanel();
        }
     
    }

    ControlPanel

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Cms.Web.UI.Backend;
     
    /// <summary>
    /// Summary description for TestModuleControlPanel
    /// </summary>
    public class TestModuleControlPanel : ProviderControlPanel<TestModuleControlPanel>
    {
        public TestModuleControlPanel()
        {
        }
     
        protected override void CreateViews()
        {
            base.CreateViews();
            AddView<SampleView>(null, "SampleView", "This is default view that shows latest items", "all", null);
        }
    }

    view

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using Telerik.Cms.Web.UI;
     
    /// <summary>
    /// Summary description for SampleView
    /// </summary>
    public class SampleView : ViewModeControl<TestModuleControlPanel>
    {
        public SampleView()
        {
        }
     
     
        public override string Name
        {
            get
            {
                return "SampleView";
            }
            set
            {
                base.Name = value;
            }
        }
     
        public override string Title
        {
            get
            {
                return "SampleViewTitle";
            }
            set
            {
                base.Title = value;
            }
        }
     
        public override string LayoutTemplatePath
        {
            get
            {
                return "~/CustomControls/TestModuleSampleView.ascx";
     
            }
        }
    }


    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.
2 posts, 0 answered