3

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!

1 Answer 1

3

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

<%:Html.DisplayFor(m => m.Date, "DateTimeWithoutLabel") %>
Sign up to request clarification or add additional context in comments.

3 Comments

DisplayFor will still add a label, regardless of what template you give it
No it won't, it will only render the content in the template. At least it works like this when i use it -.-
You not give the example for DateTimeWithoutLabel.ascx. I am searching for it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.