This project is read-only.

Necessity of N2.Futeres guide....

Nov 23, 2008 at 5:36 PM
I can't understand how to include N2.Futures tools in N2?
Please help me...
Nov 23, 2008 at 8:30 PM
Hello, SerZHio, if you're talking about N2.Futures library, posted to N2 Add-On directory, then you should go this way using it:

Given, you have a two-project solution:
  •   A library project, where you've defined your entity classes (ContentItem descendants),
  •   An ASP.Net application project where templates for your entities resides.

To benefit from N2.Futures, you first add it to your solution:

  1. [Solution Explorer] -> Add.. -> Existing Project...
  2. Update 3 references in N2.Futures project to point to a correct locations of N2.dll, N2.Templates.dll and Castle.Core.dll
  3. Now, depending on what functionality you'd like to use, click Add Reference.. to refer to it from either your entity library OR a web application.

Now, let's go straight to what you can actually do with N2.Futures:

Scenario 1: Use a user-control (.ascx) as a property/entity editor.

1.1) Add an .ascx control to your web application, which you want to be an editor for your property/entity (it should normally go into ~/MyApplication/UI/*.ascx ). Ensure your control exposes some public property to contain a value being edited ("ControlProperty") OR a property of your entity type to contain a whole entity ("CurrentItem").
1.2) Refer to N2.Futures from your entity library
1.3) Decorate your entity class with [WithEditableUserControl("My Property Title", "~/MyApplication/UI/MyControl.ascx", "", "CurrentItem", 100, "")] OR do the same just for a single property: [EditableUserControl("My Property Title", "~/MyApplication/UI/MyControl.ascx", "ControlProperty", "", 100, "")]

Scenario 2: Explore features of the UserTree control

2.1) Include N2.Futures into your solution, correct references as above.
2.2) Reference N2.Futures from your web application.
2.3) Enable Membership roles in your web application (Either by adding <roleManager enabled="true"/> somewhere under <system.web/> OR using the WSAT tool from VisualStudio)
2.4) Add a test .aspx page with the following content:

<%@ Page Language="C#" %>
<%@ Register
        Namespace="N2.Web.UI.WebControls.Test"  %>
<html xmlns="" >
<head runat="server"><title>User Tree Demo</title>
    <form id="form1" runat="server">
        <n2:UserTreeTestBed runat="server" />
What you should see now navigating to this page (if everything goes smoothly), should look like on the picture: [ ].

Also, I've uploaded a complete solution with a configured database: [ ] (2.4MB archive)

Nov 23, 2008 at 9:39 PM
Edited Nov 23, 2008 at 9:50 PM
It's great!
It seems, on screenshots, that you are from Russia? I'm too...
Could I ask you if i'll feel some troubles with N2?
And another question - how did you realize asp.membership profiles usage and editing in N2?
Please explain me!
Thank you in advance.
Nov 24, 2008 at 6:01 PM
Priviet, SerZHio ! well, almost, i'm from Ukraine, though the language is the same :-) sure, i'll do my best to help, feel free to ask in Russian (i c q 162 261 333 if you like)..

As to the membership in N2: Cristian has made a great deal of suport for editing a standard ASP.Net Roles and Membership.

(Interestingly, it's possible to use these bits without N2: you just grab [ ~/Edit/Membership ], put it into your ASP.Net app -- and instantly achieve user and roles editing without any reference to N2! I know people all over the net frequently ask for such thing, so even commercial solutions exist, not counting numerous attempts to hack a standard Visual Studio Web Site Administration Tool to work outside of VS.Net.)

There is no easy way to edit Profiles visually, even in N2. Actually, i suppose it's feasible to utilise a web property grid for this task. Having this done well, will possibly convince Crisitan to include it into N2.Edit ;-).

As to the Profile provider implementation in N2.. Actually, i'd stay with a standard SqlProfileProvider. Good news is that it works completely separately from Role and Membership providers, so you can user N2's membership and roles (thus keeping this information within N2 hierarchy), and outsource profiles to a SQL server database.

User profile itself is just a weakly typed collection of properties -- a System.Web.Profile.ProfileBase, abstracted by a provider -- much like a pure ContentItem without any typed properties defined, so you can only use GetDetail/SetDetail to access properties and then cast them to a desired type. SqlProfileProvider is much trickier than that: not only it keeps current user's property collection in a database, it also creates a statically typed class -- a ProfileCommon, wich you usually access with this.Profile property within your web form, with a true, strongly typed properties, basing on a data you defined inside <profile/> section of the web.config. Under the hood, this SqlProfileProvider cares about synchronizing any changes you make to web.config with both ProfileCommon class and a database. I'm afraid this machinery wouldn't play so well with another profile providers.
Nov 25, 2008 at 5:53 PM
Wow, I hadn't seen this before. It looks very cool. How come the ensure child attribute is obsoleted? The generic list wrapper looks very useful too.

I could see the property grid as an extension to the page editing. To edit things like publish/expire, visibile and so on.
Nov 26, 2008 at 8:57 PM
Glad you liked it :-) Now i'll try to give it a spin on a weekend. I think it'd be nice to have a "civilized" Edit menu, as presently + a "hardcore" Properties mode, available for some "superadmin" to edit any item's property unconditionally.