Umbraco: How to Create Custom data type in umbraco using c#.


Umbraco provide a great way to define or create own custom data type by several method. One of the easy method which we will see here through .Net Custom user control.

Custom Data type related post : Umbraco: XML Serialization of custom data type value in umbraco.

Why we need to create custom data types in umbraco.
Well umbraco provide by default 20 data types other than it if we need certain functionality like showing list of macro, drop-down list , color picker and any thing then we can’t achieve functionality with the help of default data type. We have to look at some another way to define own data type, In this post I will show How to add dropdown list value.

Umbraco provide interface for create custom data type.

Umbraco Interface:  umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor

Reference Dll : umbraco.editorControl

In Interface: Umbraco has created Property which will used to store value it’s manage by umbraco so no need to give much attention here.

The code Part in .Net:

CustomFontDropDown.ascx.cs File

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.editorControls;
using umbraco.cms.businesslogic.web;

namespace UmbracoCustomDataTypes.usercontrols
    public partial class CustomFontDropDown : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor

        public object value
                return drop1.SelectedValue;
                drop1.SelectedValue = value.ToString();

        protected void Page_Load(object sender, EventArgs e)
            if (Page.IsPostBack)


        protected void Button1_Click(object sender, EventArgs e)
            string dropDownValue = string.Empty;
            dropDownValue = value.ToString();
            Label1.Text =  "You have selected this"+ dropDownValue;

Explanation:CustomFontDropDown inherit umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
interface and umbraco Interface containing property value which has type object. Here CustomFontDropDown class will
set Umbraco interface value.

CustomFontDropDown.ascx File

  <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CustomFontDropDown.ascx.cs" Inherits="UmbracoCustomDataTypes.usercontrols.CustomFontDropDown" %>
<asp:DropDownList id="drop1" runat="server">
    <asp:ListItem>Item 1</asp:ListItem>
    <asp:ListItem>Item 2</asp:ListItem>
    <asp:ListItem>Item 3</asp:ListItem>
    <asp:ListItem>Item 4</asp:ListItem>
    <asp:ListItem>Item 5</asp:ListItem>
    <asp:ListItem>Item 6</asp:ListItem>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

Now Go to Umbraco developer section and create new datatype and use CustomFontDropDown user control and make sure that you
have choosed Render control as umbraco usercontrol wrapper.After that you use is as general data type.

Another Umbraco Article

Here Some another Link which will helpful in this regard.

Download Working File


4 thoughts on “Umbraco: How to Create Custom data type in umbraco using c#.

  1. Net grid performance is very fast .A programmer may create any arbitrary classes in application. Objects of these classes are associated with grid rows, and their properties are associated with grid columns. Values returned by getters of these properties are displayed in grid cells

  2. Pingback: Umbraco: How to Log or store error in umbraco Log Table by c#. | [Code Destination]

  3. Pingback: Create your first Rss Feed Burner in umbraco | [Code Destination]

  4. Pingback: Install umbraco manually. | [Code Destination]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s