0

I want to override the template for the date field input. I am using Visual Studio 2017, ASP.NET Core 2.1 and Razor Pages. I read on different pages to put the template in

\Views\Shared\EditorTemplates\Date.cshtml

but this file will be ignored.

At the Moment the Standard template inserts a field, that results in HTML5 Standard date selector which is terrible in Edge, especially for birthdates. I want to replace it with the jquery datepicker.

As long as the type is date the HTML5 selector will be displayed together with the datepicker, which is not usable.

I want to Change the type in the template and the class. I create a Date.cshtml:

 @model  DateTime
   Test Date Box
   @Html.TextBox("", Model.Date, new
       {
           @class = "datePicker",
           @readonly = "readonly"
       }))

and put this in \Pages\Shared\EditorTemplates but it didn't work. Even in \Views\Shared\EditorTemplates it did not work.

Does anyone have an idea?

Best regards

David

  • Can you please add more details ? What is there in the Date.cshtml ? What do you want to override ? – Praveen Rai Aug 17 '18 at 14:26
  • Details added in original post – D. Zinzius Aug 20 '18 at 11:07
  • You mean to say that u wish to override VS scaffolding templates ? If yes, then please try this : https://stackoverflow.com/a/39503291/7491048 – Praveen Rai Aug 20 '18 at 11:51
  • I don't want to change the scaffolding template. I want to override only the partial for the date field which is somewhere defined. Similar like "Override vierw, partial views, and pages" in this article: https://learn.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-2.1&tabs=visual-studio – D. Zinzius Aug 20 '18 at 15:26
  • Did you find a solution? – phifi Feb 06 '20 at 13:03
  • No, I used the template that was there…. – D. Zinzius Feb 07 '20 at 16:04

1 Answers1

0

you may use classic HTML inputs instead of HTML helpers and use other date picklers like jquery etc.

Ozan BAYRAM
  • 2,780
  • 1
  • 28
  • 35