“Html.DroppableZone(“h1”).Render()”上的 N2 NullReferenceException
我目前正在评估 N2 CMS 用于多个网站。
我们只想向客户提供“拖动”功能,这意味着他们可以将部件添加到页面上的区域,填写它们,然后拖动它们。管理区的“后端”功能将保留给开发人员。
因此,我不使用SlidingCurtain控件来渲染。现在,我已经制作了一个自定义管理面板,当具有正确角色的用户登录时会显示该面板。通常,当您单击“拖动”功能时,滑动窗帘会向您的 URL 添加“?edit=drag”查询字符串按钮,因此我在登录后自动添加此查询字符串。
如果这样做,我会在以下行中收到 NullReferenceException: Html.DroppableZone("H1").Render();
截至目前,该 DroppableZone 上还没有任何部件,我想这就是导致此问题的原因。我该如何解决这个问题?
我有以下 H1Controller:
namespace EmptyCMS.Controllers
{
[Controls(typeof(Models.H1))]
public class H1Controller : ContentController<Models.H1>
{
public override ActionResult Index()
{
return PartialView("H1", CurrentItem);
}
}
}
和以下部分视图:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Models.H1>" %>
<h1><%= Model.Text %></h1>
这是我的模型:
namespace EmptyCMS.Models
{
[PartDefinition("H1")]
[AllowedZones("H1")]
public class H1 : ContentItem
{
[EditableTextBox("Text", 100)]
public virtual string Text { get; set; }
}
}
谁能发现我做错了什么?非常感谢您能给我的任何帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只检查是否为空?
Just check for null?