More detailed post related to the ‘master of datatypes’ session on the fact that it is possible to store parseable xml data on your custom datatypes using the usercontrolwrapper.
A feature that was added to the usercontrolwrapper since the umbraco Juno release (4.6) was that if you returned some xml (as a string) it will recognize this and store it as parseable xml data (like the related links datatype or the image cropper datatype, basicly datatypes that store rich data, not just a single value). By storing this as xml it’s easy to work with in both xslt and razor.
As a final piece to the puzzle we also added some helper methods that you can use to serialize an object to xml, found in the umbraco.editorControls.userControlGrapper.SerializationHelper namespace (so no need to write custom to xml methods but simply use the helper methods).
Here is an example:
public partial class MultipleValuesDatatype : System.Web.UI.UserControl
protected void Page_Load(object sender, EventArgs e)
customControl.Values = _umbval;
private List<string> _umbval;
public object value
if (value != null && string.IsNullOrEmpty(value.ToString()))
_umbval = new List<string>();
The object get’s serialized (it’s of the type list<string> in this case) and the xml representation of the object gets stored.
If you take a look at the xml cache (open the /app_data/umbraco.config file) you can see how the xml representation looks (where openingHours is the alias of the property)
So in this case I get an ArrayOfString element with a string element for each of the values.
To output this on our frontend we can use some xslt or since the razor implementation in Umbraco 4.7 has awesome support for xml properties we can also use some razor:
<umbraco:Macro runat="server" language="cshtml">
@foreach(var value in Model.openingHours)
So as you see the latest updates to the usercontrol wrapper (configuration with data editor settings and the parseable xml support) make it a lot more useful and there should hardly be a need for using anything else when you want to create a custom Umbraco datatype
Download the entire sourcecode here