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

Forums / Developing with Sitefinity / The ViewMode "ContentItemsView" is not defined for this control. error with a custom module

The ViewMode "ContentItemsView" is not defined for this control. error with a custom module

3 posts, 1 answered
  1. David van Geel
    David van Geel avatar
    59 posts
    Registered:
    19 Aug 2009
    12 Aug 2010
    Link to this post
    Hi,

    I have developed a custom module (based on the generic content module) and it's working fine. :) The only issue that I can not find a sollution for is when I click on a category name in categories list. When I do that I get the following error.

     

    Serverfout in toepassing /.

    The ViewMode "ContentItemsView" is not defined for this control.

    Beschrijving: Er is een onverwerkte uitzondering opgetreden tijdens het uitvoeren van de huidige webaanvraag. Raadpleeg de stacktracering voor meer informatie over deze fout en de oorsprong ervan in de code.

    Details van uitzondering: System.ArgumentException: The ViewMode "ContentItemsView" is not defined for this control.

    Fout in bron:

    Er is een onverwerkte uitzondering gegenereerd tijdens het uitvoeren van de huidige webaanvraag. Aan de hand van de onderstaande tracering van de uitzonderingsstack kunt u meer informatie verkrijgen over de oorsprong en de locatie van de uitzondering.

    Stacktracering:

    [ArgumentException: The ViewMode "ContentItemsView" is not defined for this control.]
       Telerik.Cms.Web.UI.ViewModeControl`1.get_CurrentView() +146
       Telerik.Cms.Web.UI.ViewModeControl`1.LoadCurrentView(Control owner) +25
       Telerik.Cms.Web.UI.ViewModeControl`1.InitializeControls(Control viewContainer) +42
       Telerik.Cms.Web.UI.Backend.ControlPanel`1.InitializeControls(Control container) +23
       Telerik.Cms.Web.UI.ViewModeControl`1.CreateChildControls() +101
       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.Control.PreRenderRecursiveInternal() +171
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
    

    Ok, the categories view has been defined as follows.

    using System;
    using Telerik.Cms.Engine.WebControls.Admin;
      
    namespace Estate.SitefinityModules.Cases.WebControls.Admin
    {
        /// <summary>
        /// Categories View for cases module
        /// </summary>
        public class CasesCategoriesView : CategoriesView<CasesControlPanel>
        {
      
            /// <summary>
            /// Gets the type from the assembly containing the embedded resources.
            /// Cannot be null reference.
            /// </summary>
            /// <value></value>
            public override Type AssemblyInfo
            {
                get
                {
                    return typeof(GenericControlPanel);
                }
                set
                {
                    base.AssemblyInfo = value;
                }
            }
      
            /// <summary>
            /// Gets the type from the assembly containing the embedded localization resource.
            /// Override if embedded templates are using ASP.NET localization.
            /// </summary>
            /// <value></value>
            public override Type LocalizationAssemblyInfo
            {
                get
                {
                    return typeof(GenericControlPanel);
                }
                set
                {
                    base.LocalizationAssemblyInfo = value;
                }
            }
              
        }
    }

    I think I need to override the DataBound method of the repeater which is used to create the list of categories but I cannot find the correct method to override. Is this the correct approach?

    Regards,


    David
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Aug 2010
    Link to this post
    Hi David van Geel,

    Here is a sample code that illustrates how to implement the view

    public class ModuleCategoriesView : CategoriesView<ModuleControlPanel>
       {
           #region Properties
     
           protected override string LayoutTemplateName
           {
               get
               {
                   return ModuleCategoriesView.ModuleCategoriesTemplateName;
               }
           }
     
           [WebSysTemplate(ModuleCategoriesView.ModuleCategoriesTemplateName, "CategoriesView_Template_Desc", "/Module/", false, "2008-11-27")]
           public override string LayoutTemplatePath
           {
               get
               {
                   return layoutTemplatePath;
               }
               set
               {
                   layoutTemplatePath = value;
               }
           }
     
           #endregion
     
           #region Overriden methods
     
           /// <summary>
           /// Navigates to ContentItemsView.
           /// </summary>
           /// <param name="filterExpr">The filter expression.</param>
           protected override void RedirectOnOpenContent(string filterExpr)
           {
               NavigateHostCommand<ModuleItemsView>(filterExpr);
           }
     
           #endregion
     
           #region Private fields
     
           string layoutTemplatePath;
     
           #endregion
     
           #region Constants
     
           private const string ModuleCategoriesTemplateName = "Telerik.Samples.Resources.ControlTemplates.Backend.ModuleCategoriesView.ascx";
     
           #endregion
       }

    In your control panel -MyControlPanel you should have the view defined as shown below

    protected override void CreateViews()
    {
     
        AddView<ModuleCategoriesView>(null, "Categories", "CommandPanel_Categories_Desc", "cat", Messages.ResourceManager);
       
    }


    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
    Answered
  3. David van Geel
    David van Geel avatar
    59 posts
    Registered:
    19 Aug 2009
    05 Nov 2010
    Link to this post
    Hi Ivan,

    It has taken me -due to other projects- a long time to get back to this but your answer solved the issue!.

    Thanks a lot.

    David
Register for webinar
3 posts, 1 answered