I'm wondering how to insert a <input type="date"/>
for datetime attributes of my model.
As for now Razor creates a plain input element with type="datetime"
. I want to make use of the new input types of HTML5.
相关问题
- TextBoxFor decimal
- How to create anchor href using Html.Helper [dupli
- How to do an inline style with asp.net mvc 3 razor
- Issue with updating model on AJAX “POST”
- Value cannot be null or empty.\r\nParameter name:
相关文章
- HTML5 control
- MVC CDN fallback for Style Bundle
- Add to htmlAttributes for custom ActionLink helper
- Breakpoint in ASP.NET MVC Razor view will not be h
- How to define function that returns html in asp.ne
- Disable action method from being called from the a
- User.Identity.IsAuthenticated vs WebSecurity.IsAut
- Is there a way to update asp.net mvc bundle conten
I managed to do it by using the following code.
The input date value format needs the date specified as per http://tools.ietf.org/html/rfc3339#section-5.6 full-date.
So I've ended up doing:
I did try doing it "properly" using:
with
Unfortunately that always seemed to set the value attribute of the input to a standard date time so I've ended up applying the formatting directly as above.
Edit:
According to Jorn if you use
instead of TextBoxFor it all works fine.
You will get it by tag type="date"...then it will render beautiful calendar and all...
If you want to use @Html.EditorFor() you have to use jQuery ui and update your Asp.net Mvc to 5.2.6.0 with NuGet Package Manager.
@section Scripts {
}