Created
June 25, 2012 07:37
-
-
Save kristofclaes/2987174 to your computer and use it in GitHub Desktop.
HomeController.cs
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
using System; | |
using System.Web.Mvc; | |
namespace MvcApplication21.Controllers | |
{ | |
public class HomeController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
return View(new Models.TestModel { DateNaissance = DateTime.Now }); | |
} | |
} | |
} |
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
@model MvcApplication21.Models.TestModel | |
@{ | |
ViewBag.Title = "Index"; | |
} | |
<h2>Index</h2> | |
@using (Html.BeginForm()) { | |
@Html.ValidationSummary(true) | |
<fieldset> | |
<legend>TestModel</legend> | |
<div class="editor-label"> | |
@Html.LabelFor(model => model.DateNaissance) | |
</div> | |
<div class="editor-field"> | |
@Html.EditorFor(model => model.DateNaissance) | |
@Html.ValidationMessageFor(model => model.DateNaissance) | |
</div> | |
<p> | |
<input type="submit" value="Save" /> | |
</p> | |
</fieldset> | |
} | |
<div> | |
@Html.ActionLink("Back to List", "Index") | |
</div> |
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
using System; | |
using System.ComponentModel.DataAnnotations; | |
namespace MvcApplication21.Models | |
{ | |
public class TestModel | |
{ | |
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)] | |
public DateTime DateNaissance { get; set; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment