Created
March 23, 2015 20:02
-
-
Save TheDarkTrumpet/9255ec35f3394ab14449 to your computer and use it in GitHub Desktop.
Please use DisplayFor, especially on dates
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ///////// In model..... ////////////////// | |
| [DisplayName("Warranty Expiration Date")] | |
| [DataType(DataType.Date)] | |
| [DisplayFormat(DataFormatString = "{0:d}", ApplyFormatInEditMode = true)] | |
| public DateTime? WarrantyExpiryDateTime { get; set; } | |
| ///////// In View..... ///////////////// | |
| @Html.EditorFor(model => model.WarrantyExpiryDateTime, new {maxlength = 10, @class = "datePicker"}) | |
| //////// In a view that iterates (iEnumberable) //////////// | |
| @foreach (ComputerAsset item in Model) | |
| { | |
| <tr> | |
| ..... | |
| <td>@Html.DisplayFor(i => item.DateAcquired)</td> | |
| ..... | |
| </tr> | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment