How to create additional template pages in VB.NET?

Topics: Developer Forum
Aug 12, 2008 at 12:53 AM

Good Morning,

I am very impressed with n2 cms and have just about got it working on my first website. I would now like to add an additional 5 template pages - all with unique html/image content. I copy the PageItem.vb file to "Page1Item.vb", and rename it's class to "Page1Item", instead of "PageItem". I then copy default.aspx to default_2.aspx, and update the code behind to it makes reference to "Page1Item". I then get the following error:

Object with id: 2 was not of the specified sublcass: N2.ContentItem (Discriminator was: 'PageItem')
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: NHibernate.WrongClassException: Object with id: 2 was not of the specified sublcass: N2.ContentItem (Discriminator was: 'PageItem')

Source Error:

Line 36:         <div>
Line 37:             <!-- This is a way to inject data into a webforms control, in this case we're injecting the current page's text property -->
Line 38:             <asp:Literal ID="TextLiteral" Text="<%$ CurrentPage: Text %>" runat="server" />
Line 39:         </div>
Line 40:    </td>

I saw the C# example where you can specify the TemplateUrl. How can I do this in VB.NET?
<Definition("My First Page")> _
    Public Class MyPagePage
        Inherits N2.Templates.Items.AbstractContentPage
        Public Overloads Overrides ReadOnly Property TemplateUrl() As String
            Get
                Return "~/UI/MyPage.aspx"
            End Get
        End Property
    End Class 

It is saying that N2.Templates.Items.AbstractContentPage is invalid.

Can anyone give me an example of a template and code in VB.NET, please?

Thanks,

turpya.

Coordinator
Aug 12, 2008 at 5:23 PM
Hi, the problem is that there is content data in the database bound to the old content class (if you instead add a new one you're okay). You can either update the discriminator string to 'Page1Item" or recreate the database nodes through /edit/install.