1

I have an EditableDate property and am displaying it in a WebForms page with <n2:Display> tag. The default output is something like 7/02/2011 12:00:00 AM however I would like to format the date like 7 February 2011. Have tried <n2:Display Format="{0:d MMM yyyy}"> however this just outputs {0:d MMM yyyy}.

yanta
  • 841
  • 1
  • 9
  • 19

2 Answers2

0

Not sure about this: could it be that you only need the formatting part?

<n2:Display Format="d MMM yyyy">
Grimace of Despair
  • 3,436
  • 26
  • 38
0

In your ContentItem, add a new property like "XDateString" as follow :

...
[EditableDate("Date", 50, ContainerName = Tabs.Content)]
public virtual DateTime? EventDate
{
      get { return (DateTime?)GetDetail("EventDate"); }
      set { SetDetail("EventDate", value); }
}

public virtual string EventDateString
{
     get
     {
         if (!EventDate.HasValue) return string.Empty;

         //Format here your Date
         return (EventDate.Value.ToString("d") + " " +
                 EventDate.Value.ToString("MMMM") + " " +
                 EventDate.Value.ToString("yyyy") 
                );
     }
}
...

Then in design page, add :

<n2:Display runat="server" PropertyName="EventDateString"/>
Samidjo
  • 2,315
  • 30
  • 37