Do not use DateTimeField when displaying the date of your field
I have a “DateTime-field” inside a list which contains both date and time. In order to allow the user to edit this information inside the publishing page I used the
If you only want to display that field-value you can simply use the
ControlMode-property and set it to
Display. If you want to display only the date-part of that datetime just set the
Thats the theory. If you do it like that you get a nice
Object reference not set to an instance of an object-error. The cause is
Reflectoring the control reveals that when the control is in “DisplayMode” the inner
DateTimeControl is not created and that is why
DateOnly cannot be set.
Its seems this control was developed by a drunken programmer as my friend stated out a bug in this control a while ago.