How can I create editor templates for Nullable <DateTime> as well as DateTime?

What is the nameplate template files my main question? If if has @model DateTime? in one, can I use it for a direct DateTime?

MS seems to have dropped the ball with the editors for some null values.

+4
source share
1 answer

It is quite simple to configure.

As an @model DateTime? model @model DateTime? . Name the file DateTime.cshtml .

Depending on how you plan on rendering your inputs, you may have to have some logic in the template along the lines

 @if (Model == null) { // do this } else { // do that } 
+4
source

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


All Articles