Custom renderer for PropertyDateControl doesn't work


I've tried to create a "DateFormat"-renderer where you can specify a format for a date property (duh :)).

Nothing strange at all really:

[TemplateDescriptor(TagString = "FormatDate")]
public class FormatDate : PropertyDateControl, IRenderTemplate<DateTime>
public override void CreateDefaultControls()
{ // Code here... } }

But if I change the class to inherit from PropertyStringControl and IRenderTemplate<string> instead, it works for string properties.
Anyone else had this problem?
Jun 25, 2013 13:15

It sounds like there could be something wrong with your Property. Can you explain how your Property is created? Also have a look in Admin mode to check whether your Property accually is stored as a DateTime.

Also, personally I would prefer to use PropertyControlBase if you only want to render for visitor and not change the behaviour for editors.


Jun 25, 2013 13:47

It's not a custom property, It's EPiServers default Date property.
I can agree with you but in this case, the date is to be formatted when the editor is editing too.

I took that exact code and it works for string properties but not for the date property. Hmm. Any more ideas?

Jun 25, 2013 13:56

Hi, I meant how you add the Property to your Page Type? Manually or by code?

Jun 25, 2013 15:00

By code ofc. :)

			Name = "Datum",
			Order = 10
		public virtual DateTime Date { get; set; }


Edited, Jun 25, 2013 15:01

Could you give what the code looks like?
Also, have a look in Admin mode at the Property to tell whether EPiServer have interpreted your code and updated the database correctly. When the behaviour on Properties isn't what I expect, I usually find some clues here.

Jun 25, 2013 15:03

Ah replied before I saw your code.

This seems to look correct. Now is the questions if EPiServer has the correct values in the database?

Jun 25, 2013 15:09

Yes, I checked that too and the property definition type is 5, which is Date.

This must be a bug?

Edited, Jun 25, 2013 15:15

Where are you telling the property to use the renderer tagged "FormatDate"? Are you adding a tag to the property webcontrol or propertyFor call?

Jun 25, 2013 16:38
<episerver:property propertyName="Date" customTagName="span" cssClass="date" runat="server">
	<renderSettings tag="FormatDate" />
Jun 25, 2013 16:39

I can't replicate having an EditorDescriptor for a DateTime either.

I've tried creating classes inheriting PropertyDateControl and PropertyControlBase<DateTime>.

It seems like the TemplateResolver doesn't register these Templates correctly?

Should something more be specified on the TemplateDescriptor?

Jun 25, 2013 17:02


I have reproduced the issue, created a bug and also made a fix since it was a quite small change. The bug for further tracking is:

Bug #101219: It's not possible to add custom renderers to some built in property types

Jul 01, 2013 15:28

Lovely! :)

Jul 01, 2013 16:00

Hi Linus,

This is fixed in the release of 7.5 today?

Dec 03, 2013 22:31

Yes, this bug should be fixed in the 7.5 release.

Dec 04, 2013 9:57
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.