Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
XML
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}")

Above code not work for me . Kindly help me please
Posted
Updated 24-Jul-14 21:55pm
v2

Try this:
C#
@Html.TextBoxFor(m => m.MyDate, new { Value = Model.MyDate.ToString("DD:MM:YYYY")});


   -Amy
 
Share this answer
 
Try this :
@Html.TextBoxFor(m => m.MyDateTime, new { Value = Model.MyDateTime.ToString("MM-dd-yyyy"), id = "MySuperCoolId"});

or

@Html.TextBox("StartDate", string.Format("{0: d}", Model.StartDate))
 
Share this answer
 
v2
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900