Virtual Happy Hour this month, Jun 28, we'll be getting a sneak preview at our soon to launch SaaS CMS!

Try our conversational search powered by Generative AI!



How do you use the timespan as property on a block, for example showing a store openinghours?


E.g. this:

[ContentType(GUID = "714C5D3A-4AB2-43BE-A50C-28DD9C5E46AC", AvailableInEditMode = false)]
public class OpeningHour : BlockData
[Display(Name = "Opens")]
public virtual TimeSpan Open { get; set; }

[Display(Name = "Closes")]
public virtual TimeSpan Close { get; set; }



he property 'Open' on content type 'OpeningHour' is of type 'System.TimeSpan' that cannot be backed by PropertyTimeSpan, it only only supports types Int32, Enum.


And removing the backing type prop gives : 

The backing type 'EPiServer.SpecializedProperties.PropertyTimeSpan' is not a registered PropertyDefinitionType


What am i missing? 

Aug 15, 2013 15:35

It's hard to say without seeing PropertyTimeSpan sorce code. Check that PropertyTimeSpan.PropertyValueType property is implemented and returns TimeSpan type.

Aug 19, 2013 11:31


thanks for answering, but the PropertyTimeSpan code is from episerver.


Aug 22, 2013 14:09

Ah, yes. Did you try without BackingType attribute for TimeSpan properties? I think it should be assigned automatically.

[Display(Name = "Closes")]
public virtual TimeSpan Close { get; set; }


Aug 23, 2013 9:57

Hi Per!

Have you tried to register the EPiServer.SpecializedProperties.PropertyTimeSpan via the GUI in admin mode?

class name EPiServer.SpecializedProperties.PropertyTimeSpan, assembly name EPiServer, base type number.






Aug 23, 2013 13:54

@Dmytro yes I tried without backingtype. 

@Tarjei, thanks. Registered it (don't know why it's not there already). I get a different edit mode dialog, a textbox and a dropdownlist with days, hours, minutes. Not quite what I expected and cannot save the value in edit mode even if I try different backing types (integer, floating point, string... )


Aug 28, 2013 9:30

Ok, maybe thats the reason why the TimeSpan property is gone from the list of registered property types …

Perhaps it is better to simply use a string property and a validator to get the input parseable as a TimeSpan. That would be easy for editors, a bit more hassle for you when you have to pase the string data, but you can use a UIHint and a display template to get it right every time when rendering. Or you can go all the way and make a block type (AvailableInEditMode=false) with several inputs, drop down lists and what not and force e timespan out of it.



Aug 30, 2013 10:31
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.