这里是我的模型:我怎样才能保持(asp.net的MVC)的行动之间模型的属性
public class MyModel
{
public int BaseTypeField { set; get; }
public MyType UserTypeField { set; get; }
}
在第一个动作,我通过了为MyModel到视图通常:
public ActionResult Action1()
{
MyModel model = new MyModel();
//do something with model.UserTypeField
return View(model);
}
在Action1View我可以很容易地修改model.BaseTypeField用的HtmlHelper,但我不想修改model.UserTypeField在该视图(我也不能存放在HiddenFor)。 然后Action1View提交模式到另一个动作:
public ActionResult Action2(MyModel model)
{
//model.UserTypeField is lost here
return View();
}
这里谈到的问题:我如何才能保持/保存model.UserTypeField除了类似会议?
为什么你不能把它放在一个隐藏字段? – hatchet
防止隐藏字段丢失的唯一方法是:<%= Html.HiddenFor(o => o.UserTypeField.EveryFieldInUserField.MaybeSomeOthers)%>。这太烦人了吗? – rhapsodyn