This project is read-only.

Can't create parts.

Topics: Developer Forum
Aug 31, 2008 at 5:44 AM
I have read all the tutorials and getting started guides for n2cms.

I am trying to create a box for my page (that is a content item).

When "Organizing Parts", I want to be able to see Box1 and be able to drag and drop it.

I have created the Box1 class like this...
<WithEditableTitle("Title", 10)> _
<N2.Definition("Box1", "Box1")> _
<AllowedZones(New String() {"RecursiveRight", "RecursiveLeft", "Left", "Right", "TestDroppableZone", "TestZone"})> _
Public Class Box1
    Inherits N2.ContentItem

    Public Overrides ReadOnly Property TemplateUrl() As String
        Get
            Return "~/UI/Composition/Box1.ascx"
        End Get
    End Property
    Public Overrides ReadOnly Property IsPage() As Boolean
        Get
            Return False
        End Get
    End Property

    Private _ContentBody As String
    <EditableFreeTextArea("Content", 1)> _
    Public Property ContentBody() As String
        Get
            Return _ContentBody
        End Get
        Set(ByVal value As String)
            _ContentBody = value
        End Set
    End Property

    Private _ContentTitle As String
    <EditableTextBox("Title", 0)> _
    Public Property ContentTitle() As String
        Get
            Return _ContentTitle
        End Get
        Set(ByVal value As String)
            _ContentTitle = value
        End Set
    End Property

End Class

I then created the Box1.ascx and Box1 class like this.

Partial Class UI_Composition_Box1
    Inherits N2.Web.UI.ContentUserControl(Of AbstractItem, Box1)

End Class


<WithEditableTitle("Title", 10)> _
<N2.Definition("Box1", "Box1")> _
<AllowedZones(New String() {"RecursiveRight", "RecursiveLeft", "Left", "Right", "TestDroppableZone", "TestZone"})> _
Public Class Box1
    Inherits AbstractItem

    Public Overrides ReadOnly Property TemplateUrl() As String
        Get
            Return "~/UI/Composition/Box1.ascx"
        End Get
    End Property
    Public Overrides ReadOnly Property IsPage() As Boolean
        Get
            Return False
        End Get
    End Property

    Private _ContentBody As String
    <EditableFreeTextArea("Content", 1)> _
    Public Property ContentBody() As String
        Get
            Return _ContentBody
        End Get
        Set(ByVal value As String)
            _ContentBody = value
        End Set
    End Property

    Private _ContentTitle As String
    <EditableTextBox("Title", 0)> _
    Public Property ContentTitle() As String
        Get
            Return _ContentTitle
        End Get
        Set(ByVal value As String)
            _ContentTitle = value
        End Set
    End Property

End Class

With all this code, still nothing shows up when "Organizing" a page.

Why?
Aug 31, 2008 at 7:15 AM
Edited Aug 31, 2008 at 7:22 AM
Found out why. Turns out in the content page, I have to specify which zones are available.

I now see "Box1" when editing the page.

The only problem now is that when I try to add it to the page, nothing happens. I drop it into a zone that it is allowed to, and nothing happens.

On the template/demo site, you get redirected to another page where you set the title and any other custom fields you specified on the ContentItem "Box1" class.

How come that is not happening here?
Aug 31, 2008 at 12:44 PM
I suppose you do get the green cue that you're allowed to drop something. Could it be that something goes wrong? Can you run firebug och fiddler to see if you get an error of some sort?
Aug 31, 2008 at 1:19 PM
Found something interesting...

When I try to move, there is a GET request to http://localhost:1561/move.n2.ashx?action=move&dragKey=ctl07&item=3&dropKey=dp_4&zone=Right&before=4 with the response of..

<html>
    <head>
        <title>The resource cannot be found.</title>
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
        </style>
    </head>
    <body bgcolor="white">
            <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
            <h2> <i>The resource cannot be found.</i> </h2></span>
            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
            <b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies
) could have been removed, had its name changed, or is temporarily unavailable. &nbsp;Please review the
 following URL and make sure that it is spelled correctly.
            <br><br>
            <b> Requested URL: </b>/move.n2.ashx<br><br>
            <hr width=100% size=1 color=silver>
            <b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET
 Version:2.0.50727.3053
            </font>
    </body>
</html>
<!-- 
[HttpException]: The file '/move.n2.ashx' does not exist.
   at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean
 noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath
 virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath
, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.UI.SimpleHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context
, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath
 path, String pathTranslated, Boolean useAppConfig)
   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->


When I try to create (by drag and drop), there is a GET request to http://localhost:1561/move.n2.ashx?action=move&dragKey=ctl07&item=3&dropKey=dp_4&zone=Right&before=4 with the response of...
<html>
    <head>
        <title>The resource cannot be found.</title>
        <style>
         body {font-family:"Verdana";font-weight:normal;font-size: .7em;color:black;} 
         p {font-family:"Verdana";font-weight:normal;color:black;margin-top: -5px}
         b {font-family:"Verdana";font-weight:bold;color:black;margin-top: -5px}
         H1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
         H2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
         pre {font-family:"Lucida Console";font-size: .9em}
         .marker {font-weight: bold; color: black;text-decoration: none;}
         .version {color: gray;}
         .error {margin-bottom: 10px;}
         .expandable { text-decoration:underline; font-weight:bold; color:navy; cursor:hand; }
        </style>
    </head>
    <body bgcolor="white">
            <span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
            <h2> <i>The resource cannot be found.</i> </h2></span>
            <font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
            <b> Description: </b>HTTP 404. The resource you are looking for (or one of its dependencies
) could have been removed, had its name changed, or is temporarily unavailable. &nbsp;Please review the
 following URL and make sure that it is spelled correctly.
            <br><br>
            <b> Requested URL: </b>/create.n2.ashx<br><br>
            <hr width=100% size=1 color=silver>
            <b>Version Information:</b>&nbsp;Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET
 Version:2.0.50727.3053
            </font>
    </body>
</html>
<!-- 
[HttpException]: The file '/create.n2.ashx' does not exist.
   at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean
 noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath
 virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath
, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.UI.SimpleHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context
, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath
 path, String pathTranslated, Boolean useAppConfig)
   at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
-->

Should there a httphandler in my web.config? There isn't any. I'm using the Visual Basic minimum example.

Aug 31, 2008 at 1:21 PM
Downloaded another example (Templates) and found the httphandler in the config.

This should really be included in ALL the solutions.
Aug 31, 2008 at 2:24 PM
Good idea, I've updated the examples.