Asp.net mvc textbox date format

My form contains a text box for entering a date. In the presentation, the data is used to add a row to the table. The view is strongly typed in the table.

The problem is that the database server is configured for the US date format. But users need to use the UK date format in the text box. When users enter the date format in uk format, it is thrown.

The database server configuration cannot be changed. So, what can be done so that users can enter the date in uk format?

+3
source share
3 answers

Try setting the culture in web.config :

<system.web>
    <globalization 
        requestEncoding="utf-8" 
        responseEncoding="utf-8" 
        culture="en-GB" 
        uiCulture="en-GB"/>
</system.web>
+4
source

view model. , , . , (a correctly formatted one) . AutoMapper.

0

, , , .

[DisplayFormat (DataFormatString = "{0: yyyy/MM/dd}", ApplyFormatInEditMode = true)]
public DateTime Birthday {get; ; }

.

0
source

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


All Articles