ASP.NET MVC Custom Templating without display

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

The problem I am facing is a page where the date should be displayed in the same way, but without any shortcuts or any other HTML code other than the appointed date itself. Unfortunately, with DisplayFor (m => m.Date) I get an extra label that I don't want, but with DisplayTextFor (m => m.Date) I don't get the template.

Is there a way to apply the template to my date without the extra charge that comes with DisplayFor ()?

Thanks in advance!

+3
source share
1 answer

Make another template without a label ... for example DateTimeWithoutLabel.ascx.

<%:Html.DisplayFor(m => m.Date, "DateTimeWithoutLabel") %>
+3
source

Source: https://habr.com/ru/post/1757354/


All Articles