This content is archived. See latest version here

Last updated: Aug 27 2014

Built-in auto-suggestion editor

This document describes how to create a rich-text editor that gives the editor suggestion in a dropdown list.

To implement this, just create a class that implements the new interface ISelectionQuery:

using System;
using System.Collections.Generic;
using System.Linq;
using EPiServer.ServiceLocation;
using EPiServer.Shell.ObjectEditing;
  namespace EPiServer.Samples
    public class MySelectionQuery : ISelectionQuery
        SelectItem[] _items;
        public MySelectionQuery()
            _items = new SelectItem[] { 
                new SelectItem() { Text = String.Empty, Value = String.Empty },
                new SelectItem() { Text = "Alternative1", Value = "1" },
                new SelectItem() { Text = "Alternative 2", Value = "2" } };
       //Will be called when the editor types something in the selection editor.
        public IEnumerable<ISelectItem> GetItems(string query)
            return _items.Where(i => i.Text.StartsWith(query, StringComparison.OrdinalIgnoreCase));
       //Will be called when initializing an editor with an existing value to get the corresponding text representation.
        public ISelectItem GetItemByValue(string value)
            return _items.FirstOrDefault(i => i.Value.Equals(value));

And to use this you can add the new AutoSuggestionEditor attribute to your property:

     public virtual string SelectionEditor1 { get; set; }

     [AutoSuggestSelection(typeof(MySelectionQuery), AllowCustomValues = true)]
     public virtual string SelectionEditor2 { get; set; }


Note how the second property sets the AllowCustomValues property to true. This means that the editor is not forced to select one of the suggested choices, it’s merely used for giving editors suggestions. By default, this property is set to false and the editor needs to select one of the suggested values.

Do you have feedback on this documentation? Send an email to For development-related questions and discussions, refer to our Forums on