Creating a template
So far we've defined a content class, created the database schema added the root node. To make the site complete we need to display the content. Consider the following asp.net template (aspx):
It's an empty aspx page, and the code behind file is also empty:
Extending the template
To more easily output our content we can inherit from a base class in N2. The generic part of the base class is useful since it allows us to easily access the properties we added to the content class. If a baseclass isn't an option - or you don't like base classes - you can use the N2.Web.UI.IContentTemplate interface which is injected with the current content item. You can also retrieve the data through the API:s.
Now we can use several way to output or content or bind it to web controls on the page. The example shows two ways to output content. Through the Response.Write equivalent <%= "text" %> and through the display control. Since we decorated the Text property with a EditableFreeTextArea the content will be dynamically added with a Literal control.
Finally a quick look at the page as people visiting the site will see it. You can of course use the data and the web controls in your existing aspx pages.