1. The customized display or editor templates must be in a sub-folder
=> DisplayTemplate
=> EditorTemplates
2. There sub-folders can live in "Shared" folder or a specific view folder
3. The name of the template must match the name of the type (DateTime.ascx)
Custom Date and Time Format
http://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
=====================================================
Shared > EditorTemplates > add view as a DateTime
add code
@model DateTime?
@Html.TextBox("", Model.HasValue ? Model.Value.ToString("dd/MM/yyy") : "", new {@class ="date"}) //should match a name
-------------------------------
calendar in edit form using JQuery
- need content and jquery
----------------------
Edit.cshtml----------------
<link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
<link href="../../Content/themes/base/jquery.ui.all.css" rel="stylesheet" type="text/css" />
<script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.20.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("input:text.date").datepicker({ dateFormat: "dd/mm/yy" });
});
</script>
================================
@Html.TextBox("", Model.HasValue ? @ViewData.TemplateInfo.FormattedModelValue : "", new {@class ="date"})
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}", ApplyFormatInEditMode=true)]
public DateTime? HireDate { get; set; }
//for currency issue or date type issue - on web.config
<globalization culture="en-gb" />
<globalization culture="en-us" />
==============================
<img src="@Url.Content(@Model.Photo)" alt="@Model.AlternateText" />