<%=Html.CheckBox("IsBirthday","我是否过生日", item.IsBirthday)%>
Controller:
AUser user = new AUser();
BindingHelperExtensions.UpdateFrom(user, Request.Form);
Model:BindingHelperExtensions.UpdateFrom(user, Request.Form);
public class AUser{
public bool IsBirthday{get;set;}
}
public bool IsBirthday{get;set;}
}
这样会发生无法从View中获取到IsBirthday值的情况
查了许多MS只能以以下方法解决
Controller:
AUser user = new AUser();
BindingHelperExtensions.UpdateFrom(user, Request.Form);
user.IsBirthday= Request.Form["IsBirthday"]=="true";
View:BindingHelperExtensions.UpdateFrom(user, Request.Form);
user.IsBirthday= Request.Form["IsBirthday"]=="true";
<%=Html.CheckBox("IsBirthday","我是否过生日","true", item.IsBirthday)%>
Over
同是学习,如果大家发现其它Bug欢迎交流.