如何在mvc 5中键入文本框时设置日期格式 [英] how to set the date format while typing in textbox in mvc 5

查看:76
本文介绍了如何在mvc 5中键入文本框时设置日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



这里我在文本框中设置了一个字段名称startdate但是日期格式需要(MM:DD:YYYY)现在我想要改变(DD:MM:YYYY)。可以帮助完成这项任务。



in modal:



[DataType(DataType.Date)] [DisplayFormat(DataFormatString ={0:yyyy-MM-dd},ApplyFormatInEditMode = true)] public Nullable< system.datetime> Start_date {get;组; }



IN VIews: -



@ Html.TextBoxFor(m => m.Start_date, {0:dd / MM / yyyy})

hi to all,

here i'm set a field name startdate in textbox but the date format will takes(MM:DD:YYYY) now i want to change (DD:MM:YYYY).can anybody help for this task.

in modal:

[DataType(DataType.Date)] [DisplayFormat(DataFormatString = "{0:yyyy-MM-dd}", ApplyFormatInEditMode = true)] public Nullable<system.datetime> Start_date { get; set; }

IN VIews:-

@Html.TextBoxFor(m => m.Start_date, "{0:dd/MM/yyyy}")

推荐答案

@Html.TextBoxFor(m => m.Start_date, new { Value = Model.Start_date.ToString("dd-MM-yyyy"), id = "MySuperCoolId"});


这篇关于如何在mvc 5中键入文本框时设置日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆