Try our conversational search powered by Generative AI!

Ruslan Minasian
Sep 17, 2010
(0 votes)

Use UserControl for Editing Custom Property Types

First of all, read this article by Ted Nyberg about using ETF. When I first started using EpiServer (not very long ago) I was wondering why can’t I find any examples of using UserControls in custom properties. I’m pretty sure I’m inventing my own wheel but hopefully my note will be better indexed than existing ones (I found none of them).

So, let’s create property MyPropertyString extending PropertyString.

public class MyPropertyString : PropertyString {

Looks like pretty useful property. Let’s add it to some PageType and ensure it’s displayed.

Then, we’ll add new Web User Control

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyPropertyStringControl.ascx.cs" Inherits="EPiServer1.MyPropertyStringControl" %>
<asp:TextBox runat="server" ID="txtValue"  />&nbsp;
<input type="button" value="Clear"
onclick="document.getElementById('<%= txtValue.ClientID %>').value = ''; return false;" />


public partial class MyPropertyStringControl : UserControlBase, IPropertyControl {
    public MyPropertyStringControl() {
        Enabled = true; // Do not forget this!

    public void SetupControl() {
        txtValue.Text = (string)PropertyData.Value;

    public void ApplyChanges() {
        PropertyData.Value = txtValue.Text;

    public bool DisplayEditUI {
        get { return PropertyData.DisplayEditUI; }

    public PropertyData PropertyData { get; set; }

    public PropertyDataCollection Properties { get; set; }

    public RenderType RenderType { get; set; }

    public TableRowLayout RowLayout {
        get { return TableRowLayout.Default; }

    public string ValidationGroup { get; set; }

    public bool Enabled { get; set; }


And the last line which this post is about:

public class MyPropertyString : PropertyString {
    public override IPropertyControl CreatePropertyControl() {
        return (IPropertyControl)BuildManager.CreateInstanceFromVirtualPath("~/MyPropertyStringControl.ascx", typeof(MyPropertyStringControl));

Voila – we’ve got ‘clear’ button near our textbox.


P.S. Guys, is there any good code-pasting plug-in for Live Writer?

Sep 17, 2010


Anders Hattestad
Anders Hattestad Sep 21, 2010 10:33 AM

I have done something simular like this

Kenia Gonzalez
Kenia Gonzalez Jul 4, 2012 02:33 PM

Great article. Really helpful, thanks!

Please login to comment.
Latest blogs
Join the Content Recommendations Work Smarter webinar May 8th 16.00-16.45 CET with expert Aidan Swain

Learn more about Content Recommendations, with Optimizely’s very own Senior Solutions consultant, Aidan Swain . He will discuss best practices and...

Karen McDougall | Apr 12, 2024

Plugin for Identifying and Bulk Deleting Orphaned Missing Properties in Optimizely

I am aware that the Optimizely World community has extensively discussed this topic, with numerous solutions and code snippets available to help...

Adnan Zameer | Apr 11, 2024 | Syndicated blog

Enhancing the Authoring Experience: Extending the LinkItem

The LinkItem field is one of the most demanded properties by the community, allowing editors to effortlessly create and manage links across pages a...

Santiago Morla | Apr 10, 2024 | Syndicated blog

The distinctions between Optimizely Web Experimentation and Optimizely Feature Experimentation

This blog is part of the series - Unlocking the Power of Experimentation: A Marketer's Insight. Let’s dive into Optimizely's powerful experimentati...

Holly Quilter | Apr 9, 2024