Why is DisplayFormat DataFormatString not working?

前端 未结 8 814
名媛妹妹
名媛妹妹 2020-11-29 05:27

I have a property in my view model as follows:

[Editable(false)]
[Display(Name = \"Date\")]
[DisplayFormat(DataFormatString = \"{0:yyyy/MM/dd}\", ApplyFormat         


        
8条回答
  •  无人及你
    2020-11-29 05:56

    Since You want to exclude the time to get Only Date: At Model:-

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

    At Views:-

        @Html.DisplayFor(model=> model.TheDate)
        @Html.JQueryUI().DatepickerFor(model => model.TheDate)
    

    The tutorial of the following link may help you.It works for me.

    http://ilyasmamunbd.blogspot.com/2014/02/jquery-ui-datepicker-popup-calendar.html

提交回复
热议问题