Nibble

UsercontrolWrapper + DataEditorSettings = super simple custom umbraco datatypes (with settings)

Umbraco 4.6 (Juno) introduces the data editor settings which make it a lot easier to create datatypes with custom settings (including datatypes created with the usercontrol wrapper method).

Since on this blog I have several posts about creating datatypes (using the various methods), I thought I’d also show how easy this has become in umbraco Juno, since you can combine the usercontrolwrapper with dataeditorsettings.

I’m creating the same datatype again, a textarea that has a limit on the number of characters, you can set the limit on the datatype settings

Sourcecode (including using statements it’s just 35 lines of code):

using System;
using System.Web;
using umbraco.cms.businesslogic.datatype;
 
namespace DataEditorSettings.UserControlWrapperAndDataEditorSettings
{
    public partial class CharLimitUserControl1 : System.Web.UI.UserControl,
    umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor  
    {
        [DataEditorSetting("Limit")]
        public string Limit { get; set; }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                CharLimit.Limit = Limit;
                if (!string.IsNullOrEmpty(_umbracoValue))
                    CharLimit.Text = _umbracoValue;
            }
        }
 
        private string _umbracoValue;
        public object value {
            get
            {
                return CharLimit.Text;
            }
            set
            {
                _umbracoValue = value.ToString();
            }
        }
    }
}

 

Datatype editor (usercontrol specific settings will load once a usercontrol is selected and save is hit):

image

Datatype in action on a content document:

image

4 Comments so far

  1. Josh on February 19th, 2011

    Thank you so much for this article!!!

    I downloaded your source code and created my own data type.

    Everything went better than expected.

  2. Jonathan Roberts on October 14th, 2011

    Hi, I would like to creat my own Image Cropper control for the backend of Umbraco. It would be a tool used by Admin staff to crop existing images and to store them in a root folder. Is this possible and if so how? Do you have any tips on this?

    Many thanks
    Jon

  3. Murray on October 18th, 2011

    @Jon there are a couple already available as well as the built in Image Cropper.

    http://our.umbraco.org/search?q=crop&content=project,
    The one created by Kenny is now built into umbraco, we usually use that one.

  4. Bryan on December 26th, 2012

    Thanks Jason. On the macro’s general prieertops tab I’ve got a browse prieertops button which I assume is the same thing. The Is301Redirect property is there, defined as bool and can be seen on the Parameters tab of the macro same idea as prieertops , I assume. The naming seems to be slightly different on our installation compared to what you’ve laid out which may be what’s thrown me.I’ve also added a property to the PWRedirectPage Document Type with the name IsPermanentRedirect , alias IsPermanentRedirect and type True/false .The PWRedirect Template then looks like this:I think that’s covered all the bases of course I’m using the updated .dll file in the /bin/ folder too.I’m still getting 302 responses though so I must have missed something Thanks againTom

Leave a Reply