??????????????????????????????????????????????????????????ASP.NET MVC?????????????????????????????ASP.NET MVC?????Bug????????п?????????????????????????Э????StackOverflow????ж?????????????http://stackoverflow.com/questions/1775170/asp-net-mvc-modelstate-clear
?????л??????????????????????????????????????????? ?????????????????HomeController??????????????Action????Index???÷???????????????DemoModel??????????????е????????????????ò???????????????????????????Model??????????View?С?
public class HomeController : Controller
{
public ActionResult Index(DemoModel model)
{
model.Foo += ":Changed";
model.Bar += ":Changed";
model.Baz += ":Changed";
return View("index"?? mode);
}
}
public class DemoModel
{
public string Foo { get; set; }
public string Bar { get; set; }
public string Baz { get; set; }
}
????????Action????Index?????View??Index.cshtml????????????????????????巽???Model????????????????????
//????????
@model DemoModel
@Html.LabelFor(m=>m.Foo)
@Html.TextBoxFor(m => m.Foo)
@Html.LabelFor(m => m.Bar)
@Html.TextBoxFor(m => m.Bar)
@Html.LabelFor(m => m.Baz)
@Html.TextBoxFor(m => m.Baz)
//????????
@model DemoModel
@Html.LabelFor(m=>m.Foo)
@Html.EditorFor (m => m.Foo)
@Html.LabelFor(m => m.Bar)
@Html.EditorFor (m => m.Bar)
@Html.LabelFor(m => m.Baz)
@Html.EditorFor (m => m.Baz)
//?????????
@model DemoModel
@Html.EditorForModel