using AppliWebANA.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace AppliWebANA.Controllers { public class EmployeController : Controller { [HttpGet] public ActionResult Index() { ViewBag.Poste = string.Empty; // Pour éviter la pré-sélection de la 1ere valeur de l'énum (car Employe.Poste n'est un pas annulable) return View(); } [HttpPost, ValidateAntiForgeryToken] public ActionResult Index( Employe nv ) { // Model binding => remplit le ModelState if( !ModelState.IsValid ) { return View(); // LEs TextBoxFOR lisent le ModelState } // ... Sauver ... ViewBag.Message = "OK, c'est sauvé !"; ModelState.Clear(); return View(); } } }