Wednesday, March 10, 2010

DNN Dev Zone Library Minimize
Last Updated On: 9/9/2006 5:05:58 PM
ArticlesSkip Navigation Links.  

The DotNetNuke Property Editors

Part 1: An over-view of the Profile Editor

Author: Charles Nurse
Posted: Wednesday, August 16, 2006
Last Updated: Saturday, September 09, 2006

Abstract: This article provides an introductory overview of the new Profile Editor, introduced in DotNetNuke v4.3.

Introduction

Version 4.3 of the DotNetNuke Web Application Framework introduced a suite of Property Editors. These Property Editors dynamically inject the appropriate Edit Control depending on the Data Type to be edited. There are 5 types of editor and 47 class or enum files that make up the Property Editor suite of controls. This article provides an introductory overview to the Property Editors, focussing on the Profile Editor.

The Editors

Lets first look at the top level Editors. As mentioned in the Introduction there are five types of Editor:

  • FieldEditorControl - This editor represents a single row in an Editor. It is used to edit a single "property".
    FieldEditor.png
    While it can be used on its own, it is usually used as a building block in one of the other four editors.
  • PropertyEditorControl - This editor combines many FieldEditors to form an Editor for an instance of a Class. A Fields collection can be used to define the properties of the class that are part of the editor, or if this Fields collection is not provided then the Property Editor will automaticaly generate the fields it needs from the public properties of the Class.
    Attributes can be used to decorate the properties to control the editor .
    • Browsable - is the property included
    • SortOrder - the order of property in the Editor
    • Required - whether the property is required
    • Editor - defines the Assembly Qualified Name of the editor that will be used to edit this property. If this is not defined the Editor determines the control to use based on its System.Type.
  • CollectionEditorControl - This editor combines many FieldEditors to form an editor for a collection. Rather than attributes controlling the editor, properties of the objects in the collection determine the behavior of the Editor. Thus the CollectionEditorControl has a number of properties that define which object property to use, eg
    • VisibleDataField - the property of the object that determines the objects visibility
    • RequiredDataField - the property of the object that determines if the objects is required
    • EditorDataField - the property of the object that determines the editor to use for the object
    • ValueDataField - the property of the object that holds the objects "value"
  • ProfileEditorControl - This editor is a customised version of the CollectionEditor, and is used to edit a collection of ProfilePropertyDefinition objects (Profile properties) . Properties of the ProfilePropertyDefinition object determine the behaviour of the editor (and are bound to the various "DataField"s described above).
  • Settings Editor - This editor combines many FieldEditors to form an editor for a Hashtable of settings.

In this article we will focus on the Profile Editor and how it works. In future articles we will describe how to use the other Editors in your own Modules.

Editing Profile Property Definitions

The extensible Profile included in DotNetNuke v4.3 and later provides Portal Administrators with the ability to add new Profile property definitions and edit or delete existing ones. Let us look at an example of adding a new Work Email Profile Property.

Figure 1: Adding a new Profile Property
AddProfileProperty.png
Figure 2: ProfilePropertyDefinition class definition
ProfilePropertyDefinition.png

The editor can be reached from the User Accounts module (Admin/User Accounts) by selecting Manage Profile Properties from the Action Menu, followed by Add New Profile Property from the Action Menu of the resulting page.

Figure 1 shows the resulting edit page for creating a new Profile Property, and Figure 2 shows the class definition for the ProfilePropertyDefinition object.

The ProfilePropertyDefinition class defines fifteen public properties, nine of which can be configured in the edit page and control the behaviour of the new ProfilePropertyDefinition in the Profile Editor.

  • Property Name - the name of the Profile Property
  • Data Type - the type of the Profile Property (this will determine the editor to use)
  • Property Category - the category of the Profile Property
  • Length - the maximum length for this field
  • Default Value - a default value to be used when creating new Profiles
  • Validation Expression - a regular expression that can be used to validate the data (in this case the value must be of the form abc@def.xyz using the Regular Expression - [\w\.-]+(\+[\w-]*)?@([\w-]+\.)+[\w-]+.
  • Required - determines whether the field is required
  • Visible - determines whether the field is visble to the user (admins will always see the field)
  • View Order - the order of display (within the category)

This is all the Administrator has to do to configure the various Profile properties.

Figure 3: The new Profile Property displayed in the Profile edit page.
ProfileEditor.png

Figure 3 shows the new Profile Property displayed in the users Profile edit Page. Note that there is a new Category "Contact" and the new property "Work Email" is displayed under the new category.

The arrow icon indicates that the property is required as we specified when we created the property. The red error message is displayed because the user tried to update the profile with an invalid email address as defined by the "Validation Expression".

Conclusion

This article provides an overview of the new Profile Editor introduced in DotNetNuke v4.3. It describes how to add a new Profile Property and what the various properties do.


About the Author: Charles Nurse is the owner of Keydance Computer Services, the sponsor of this site, as well as being a Trustee and a Lead Developer in the DotNetNuke project.


     
A Keydance Web Portal | Copyright 2006 by Keydance Computer Services | Privacy Statement | Terms Of Use