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

Forums / Bugs & Issues / Null Reference Error when selecting Template or Editing Template

Null Reference Error when selecting Template or Editing Template

10 posts, 0 answered
  1. Ginger
    Ginger avatar
    8 posts
    Registered:
    11 May 2009
    11 Aug 2009
    Link to this post
    I created a master page and uploaded it into Sitefinity.  When viewing the template, everything looks fine in sitefinity.  When I try to edit the template, I get a null reference exception.  I also get the same exact error if I create a page and select this template during page creation. 

    Object reference not set to an instance of an object.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

     

    [NullReferenceException: Object reference not set to an instance of an object.]

       Telerik.Cms.Web.EditPage.CreateChildControls() +280

       System.Web.UI.Control.EnsureChildControls() +145

       System.Web.UI.Control.PreRenderRecursiveInternal() +60

       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3393

  2. Vlad
    Vlad avatar
    498 posts
    Registered:
    15 Jul 2016
    12 Aug 2009
    Link to this post
    Hello Ginger,

    Is it possible, that there is another Sitefinity Web Site connected to the same database? Exactly such scenario could cause this error.
    When initializing the CMS provider, it synchronizes the templates in the database with the .master files in the ~/App_Master folder. If there are new .master files, the provider will create templates for them in the database table. If there is a template record in the database, but the corresponding .maser file is missing and there are no controls added to the template and no pages which are using it, that record will be deleted from the database.

    For example the following scenario could cause this error:
     1. You have 2 sites pointing to the same database: Site 1 (not started) and Site 2(not started);
     2. You start Site 1 and upload a new template .master file (you still haven't added controls to it, and no pages are using it).
     3. Someone else starts Site 2, and on initializing the CmsProvider removes the record for the new template from the database, because the corresponding .master file does not exist in the Site 2/App_Master folder.
     4. Then, when you go to select or edit the template, you get this error.

    Please let us know your case is different.

    Kind regards,
    Vlad
    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. Ginger
    Ginger avatar
    8 posts
    Registered:
    11 May 2009
    18 Aug 2009
    Link to this post
    Just to make sure that nothing with my configuration was causing the issue, I started from scratch with a new site and a new database. 

    1. I deleted the DB in SQL Server.
    2. I removed the virtual directory in IIS
    3. I removed the site from the Sitefinity manager
    4. I deleted the directory from the \telerik\SiteFinity3.7\WebSites directory

    I used the following steps to create the new site
    1. I created a database in SQL Server
    2. I opened Sitefinity and created the new project
    3. I edited the new project and routed it to the newly created database
    4. I created an admin account
    5. I logged into the site and added one image file to the images directory
    6. I created a new directory named css
    7. I added a new file to the new css directory
    8. I went to the pages directory and clicked on the templates link
    9. I clicked on the upload template link and selected a master template and it's code behind file and clicked upload(a simple master page that is not a nested master page)
    10. The template displays in the view window - I clicked on the Edit button
    11. Null reference error displays.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Aug 2009
    Link to this post
    Hi Ginger,

    I tried to reproduce the problem again with no success. Please take a look at the attached video. If the problem persists, please send us a sample project and your database and we will look into the matter.

    All the best,
    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.
  5. Ginger
    Ginger avatar
    8 posts
    Registered:
    11 May 2009
    20 Aug 2009
    Link to this post
    Still have the problem - Video was of what I'm trying to do.  When the video shows you clicking on the edit button of the template, is when I get the error that you didn't get.

    Where do you want me to post the files?  Do you want me to email them in?
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Aug 2009
    Link to this post
    Hi Ginger,

    It is not possible to get this error running a blank new installation. The problem could be somewhere if you met one of the Vlad's scenarios that he wrote in the previous post.

    Where do you want me to post the files?  Do you want me to email them in?


    You can open a support ticket and attach sample project where we can reproduce this problem or send us an external link from where we could download all files.

    Sincerely yours,
    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.
  7. Ginger
    Ginger avatar
    8 posts
    Registered:
    11 May 2009
    20 Aug 2009
    Link to this post
    I'm not making this up.  I recreated everything again this morning and again got the same error.  I've uploaded the files to support ticket 236658 .
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    20 Aug 2009
    Link to this post
    Hello Ginger,

    I will download the attached files and look into the matter. Then get back to you in the ticket you opened.

    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.
  9. Brinley Ang
    Brinley Ang avatar
    2 posts
    Registered:
    09 Mar 2010
    10 Mar 2010
    Link to this post
    I had encountered the exact same error. Turns out the null reference exception was thrown because of a missing form tag. i.e you need to have something like <form id="form1" runat="server"> </form> in the body.
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Mar 2010
    Link to this post
    Hi Brinley Ang,

    The Ginger's problem was the same - missing form element. Thank you for your input.

    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.
Register for webinar
10 posts, 0 answered