views:

63

answers:

1

I currently have a display template for DateTime? objects that corrects the date depending on the user's time zone. This part of the program is working fine, and when I call DisplayForModel() or DisplayFor(m => m.Date), they both use the template and display the date and time with proper formatting.

The problem I am having is I have a page where the date needs to displayed in similar fashion, but without any labels or any other HTML other than the templated date itself. Unfortunately, with DisplayFor(m => m.Date) I get an extra label I do not want, but with DisplayTextFor(m => m.Date) I do not get the template applied.

Is there a way to apply the template for my date without having all the extra mark-up that comes with DisplayFor() ?

Thanks in advance!

+2  A: 

Make another template, without the label... for example DateTimeWithoutLabel.ascx.

<%:Html.DisplayFor(m => m.Date, "DateTimeWithoutLabel") %>
Necros
DisplayFor will still add a label, regardless of what template you give it
jbabey
No it won't, it will only render the content in the template. At least it works like this when i use it -.-
Necros