Here's one possibility:
public class MyModel
{
[UIHint("MyDateTemplate")]
public DateTime Value { get; set; }
}
and in ~/Views/Home/EditorTemplates/MyDateTemplate.ascx
:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DateTime>" %>
<%: Html.TextBox(
string.Empty,
Model.ToString("dd/MM/yyyy"),
new { @class = "foo" }
)%>
and in the main view:
<%: Html.EditorForModel()
or yet another one:
public class MyModel
{
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
public DateTime Value { get; set; }
}
and in your main view:
<div class="foo">
<%: Html.EditorFor(x => x.Value) %>
</div>
and in your css:
.foo input {
/* define some rule here */
}