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

Forums / Developing with Sitefinity / Object reference not set to an instance of an object

Object reference not set to an instance of an object

11 posts, 0 answered
  1. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    19 Jun 2009
    Link to this post

    I am trying to add categories and tags functionality to my restaurants custom module. I based the module on the  "Introduction to Sitefinity Intra-Site Module Creation" webinar. The module works very well.
    Now i wanted to add similar functionality to what other modules have, such as blogs or news.

    Do that i downloaded the "Sitefinity_3_6_1936_community_ExternalTemplates", i then added it to my project. So that i could copy the appropriate files to my own module as suggested by Ivan in the webinar. I added the following files:

    CategoriesField.ascx
    CategoriesSelector.ascx
    CategoriesView.ascx

    As well as the appropriate LocalResource files.

    I then added this line:

    AddView("CategoriesView","~/Custom/Modules/Clubs/Backend/Views/CategoriesView.ascx", "Categories", "CategoriesView.", "all", null);

    To my CustomControlPanel.cs

    When loading my admin page i can see the Categories in my command panel.

    But when i click the link, i get the following error:

    Object reference not set to an instance of an object.

    [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.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

     

    Any ideas what i am missing? Should i do some changes to the ascx pages i copied?

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Jun 2009
    Link to this post
    Hello Andrew,

    It is hard to say what is the exact reason for this error, but you could try the following:
    In your custom view try to override the name of the default view

    sample:
    public class MyView : CategoriesView 
        { 
            public override string Name 
            { 
                get 
                { 
                    return "CategoriesView"
                } 
                set 
                { 
                    base.Name = value; 
                } 
            } 
     
            protected override void CreateViews() 
            { 
                 // your views go here 
            } 
        } 

    If the problem persists, write back to us.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    19 Jun 2009
    Link to this post
    Hi Ivan,

    I am afraid i am nto sure what you mean.
    Which custom view si this code supposed to go into?

    If you are refering to the CategoriesView.ascx there was no code behind file in the zipped files. Only the 'ascx'

    Is that the reason why it does not work? Where can i find this file?
    Or if i am supposed to make one myself. Could you give me a sample code for it?

    Thanks

    A
  4. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    19 Jun 2009
    Link to this post
    Just to add to my last post. I added a aspx.cs file to my aspx file (code behind)
    and put in your code into it.

    I am still getting the same error.

    I must be doing something wrong.
    What would be the steps to take if one wanted to include the categories mechanism into a custom module?

    A
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Jun 2009
    Link to this post
    Hello Andrew,

    If I correctly understand you, you have a custom module. Each module has a views. The code I have provided should be added in your view. If your approach is different please describe in details. Thus, we will be able to provide you with a solution to your problem.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    19 Jun 2009
    Link to this post
    Hi Ivan,

    Yes i am using views.
    My project is basically a copy of the project presented in the "Introduction to Sitefinity Intra-Site Module Creation" webinar.

    The structure of my project is:
    In app_code:
    ClubsControlPanel.cs
    ClubsDataClasses.dbml
    ClubsModule.cs
    ClubsView.cs

    In my "..\Custom\Modules\Contacts\Backend\Views" folder i have the following:
    ClubsEditView.ascx and .cs
    ClubsListView.ascx and .cs

    This part of the project works fine.

    At this point i have copied the
    CategoriesView.aspx as well as t's localResaurces file (there was no .cs file) from the Generic_Content folder from the Sitefinity_3_6_1936_community_externalTemplates.zip dowload.

    Adding the CategoriesView control using the addview command in my ClubsControlPanel.cs.

    At this point i started getting the error when i tried to click on the Categories link on my command panel in the admin section of the system.

    Having recieved you last email i have added a CategoriesView.acx.cs file and added the code you posted. At this point i am still getting the same error.

    Hope this is enough information for you to give me a hint where i went wrong.

    Best Regards

    Andrew
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jun 2009
    Link to this post
    Hello Andrew,

    Please send the module that you have ( you can open Bug report or give us external link for downloading) and your web.config file and I will fix the problem.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    21 Jun 2009
    Link to this post
    Thanks Ivan,

    I have created a ticket and posted my code.

    A
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    21 Jun 2009
    Link to this post
    Hello Andrew,

    Thank you for sending the files.
    I saw the thread you have opened. I will look into the matter and get back to you as soon as I have news.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    22 Jun 2009
    Link to this post
    Hello Andrew,

    I sent a reply to your bug request. Please check your tickets section.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  11. Andrew
    Andrew avatar
    202 posts
    Registered:
    05 Jun 2009
    26 Jun 2009
    Link to this post

    For all interested in this topic. I have had a discussion with Ivan outside of the forum. Now that he has explained all this to me. For those newbies like myself here is a quick summary.

    I originally intended to us the Contacts sample code to create mu own custom module. I wanted to be able to use the functionality of categories that one can see throughout the system. It is used in blogs news etc.

    Now it turns out that if you want to take this approach you have to rebuild the code for the categories functionality. It is not something available.

    There is another quicker way of approaching it. You could build a custom module on the basis of the products sample code provided. This specific sample inherits from the generic_content module and because of this inherits all the required functionality.

    In my case I predict that i will need some extra functionality and therefore have decided to build my own categories system, somewhat based on the internal one.

    So in conclusion if you are looking to build a module and want to utilise the functionality of categories tags or permissions. First look at the products sample code, it might give you a quick way of building what you need.

    Again Thanks for all your help Ivan.

    Andrew K

Register for webinar
11 posts, 0 answered