Go Back

Using Built-In Sitefinity WebEditors

In my last post, I demonstrated how to use Sitefinity's WebEditor attribute to make control property editing a bit more user friendly.  I used Sitefinity's built-in CmrUrlWebEditor for this previous example

Sitefinity comes with many more built-in WebEditors that can be used in your project.

Demo Magic / Confession

Before I proceed, I need to make a confession.  I deliberately choose the CmsUrlWebEditor for my introductory WebEditor blog post because it is very easy to use.  An earlier draft used the DhlIdEditor (example shown below). 

DhlIdEditor isn't as easy or intuitive as CmsUrlWebEditor.  During the writing process, I became mired in the specifics of DhlIdEditor, rather than the broader WebEditor concepts.  Because I wanted to write an introductory article, I ditched DhlIdEditor and went with an easier WebEditor.

I'm telling this story as a warning. 

Some built-in Sitefinity WebEditors have very specific usage requirements.  Sometimes these requirements aren't documented.  Keep in mind, these WebEditors were created for Sitefinity's internal use.  Yes, you can use them in your own custom controls, but Sitefinity might have specific needs that don't match your custom control's needs.  In those cases, it's best to create your own WebEditor.

Read my usage tips near the bottom of this post if you decide to proceed. 

Full List of Sitefinity WebEditors

All WebEditors must implement the WebUITypeEditor class.  To create the list below, I used ReSharper to find all classes that implement the WebUITypeEditor.  Some of these pages do not yet have documentation.

Using Sitefinity Built-In WebEditors

Usage for these WebEditors is going to vary.  Some WebEditors require specific data types (Guids).  Other WebEditors require that underlying properties have specific ID's.  It's not always obvious what you need to do.

If you're interested in using one of these WebEditors, my advice is to search the Sitefinity forums.  If no information is available, post a new topic and ask the team for usage details.

Using the DhlIdEditor WebEditor

The DhlIdEditor (Dynamic Hyperlink Editor) lets the user select an existing Sitefinity page and returns the URL and Guid associated with the selected page.  Because DhlIdEditor returns two values, it requires two underlying properties. 

To use DhlIdEditor your control must have two properties called PageId and NavigateUrl.  If these properties do not exist or have a different ID's, the WebEditor will not work.

Here is an example showing DhlIdEditor usage:

using System;
using System.ComponentModel;
using System.Web.UI;
using Telerik.Cms.Web.UI;

public partial class UserControls_WebEditorExample : System.Web.UI.UserControl
{
    [TypeConverter("Telerik.Cms.Web.UI.GuidTypeConverter, Telerik.Cms")]
    [WebEditor("Telerik.Cms.Web.UI.DhlIdEditor, Telerik.Cms")]
    [DefaultValue(typeof(Guid), "00000000-0000-0000-0000-000000000000")]
    public Guid PageId
    {
        get
        {
            return pageId;
        }
        set
        {
            pageId = value;
        }
    }

    [UrlProperty]
    [WebEditor("Telerik.Cms.Web.UI.DhlUrlEditor, Telerik.Cms")]
    [Bindable(true)]
    [DefaultValue("")]
    public string NavigateUrl
    {
        get
        {
            return navigateUrl;
        }
        set
        {
            navigateUrl = value;
        }
    }

    private Guid pageId;
    private string navigateUrl;

    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

Hopefully this blog post will be useful to anyone exploring the built-in Sitefinity WebEditors. 

If this all proves too much trouble, you're always free to create your own WebEditor or a Control Designer.  We'll look at these subjects in the next few days.

Comments  5

  • Brook 31 Jan

    Thanks for the post Gabe.
  • Andrei 20 Mar

    I have used the same code and when i click the select button in sitefinity i get null reference and all sorts. what may be wrong, please? thanks.
  • Steve 16 Jun

    I've been trying to get the Telerik.Cms.Engine.WebControls.Categories.CategoriesSelector to work but I get an error can't cast to string?  Any ideas?

    Error:
    [InvalidCastException: Unable to cast object of type 'System.String' to type 'System.String[]'.]
       Telerik.Cms.Web.UI.WebUITypeEditor`1.Telerik.Cms.Web.UI.IWebUITypeEditor.set_Value(Object value) +82
       Telerik.Cms.Web.UI.PropertyEditorDialog.CreateChildControls() +1122
     

    My code looks this:
    /// <summary>
        /// Gets or sets the name of the category for which the news items will be filtered.
        /// </summary>
        [Category("Filters")]
        [Telerik.Cms.Web.UI.WebEditor("Telerik.Cms.Engine.WebControls.Categories.CategoriesSelector, Telerik.Cms.Engine")]
        public string CategoryName
        {
            get
            {
                
                return this.categoryName;
            }
            set
            {
                this.categoryName = value;
            }
        }
       

  • Adam 10 Nov

    This code also gives me a null reference. Please help!
  • Jim 20 Jan

    This list is very helpful, Gabe.  Sure beats building a custom designer!
Post a comment!
  1. Formatting options
       
     
     
     
     
       
  2. I'm sorry for the CAPTCHA. You have spammers to thank for this: