1

I'm currently evaluating N2 CMS for use for multiple websites.

We would only like to offer the 'drag' functionality to our clients, which means they can add parts to Zones on the page, fill them out, and drag them around. The "backend" functionality of the management zone will be reserved for the developers.

Therefore, I don't use the SlidingCurtain control to render. Right now, I've made a custom Admin Panel that appears when a user with the correct role is logged in. Normally, the Sliding Curtain adds a "?edit=drag" query string to your URL when you click the 'drag' functionality button, so I add this querystring automatically after logging in.

If I do this, I get a NullReferenceException to the following line: Html.DroppableZone("H1").Render();

As of this moment, there are no parts on this DroppableZone yet, and I suppose this is what is causing this problem. How do I get around this?

I have the following H1Controller:

namespace EmptyCMS.Controllers
{
    [Controls(typeof(Models.H1))]
    public class H1Controller : ContentController<Models.H1>
    {
        public override ActionResult Index()
        {
            return PartialView("H1", CurrentItem);
        }
    }
}

And the following partialview:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Models.H1>" %>

 <h1><%= Model.Text %></h1>

And this is my model:

namespace EmptyCMS.Models
{
    [PartDefinition("H1")]
    [AllowedZones("H1")]
    public class H1 : ContentItem
    {
        [EditableTextBox("Text", 100)]
        public virtual string Text { get; set; }
    }
}

Can anyone spot what I'm doing wrong? Thanks a lot for any help you can give me.

BigJump
  • 15,561
  • 3
  • 31
  • 29
Steven Lemmens
  • 1,441
  • 3
  • 17
  • 30
  • It can help to get the N2 source code out of their [github](https://github.com/n2cms/n2cms) and run against a build of that so you can step into it to see exactly where it's gone wrong. I've never used the zones myself sorry – Rup Mar 29 '11 at 14:30
  • Thanks. I ended up doing exactly that. – Steven Lemmens Mar 29 '11 at 15:07
  • Continuation: I think it looks like the code has a problem with a zone if there are no parts inside the zone. But I'm guessing this can't be right. – Steven Lemmens Mar 29 '11 at 15:08

1 Answers1

0

Just check for null?

var zone = Html.DroppableZone("H1");
if(zone != null)
    zone.Render();
Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443
  • This gives exactly the same problem. The NullReferenceException is then thrown on the "zone.Render()" line. Do you happen to have any other ideas? – Steven Lemmens Mar 29 '11 at 10:51
  • This means the NRE is thrown *inside* the `Render` method. I can't help you further here, because I don't know asp.net MVC or N2. – Daniel Hilgarth Mar 29 '11 at 10:57