i have my checkbox for a bool field like so in my view:
我在我的视图中有一个bool字段的复选框:
=Html.CheckBox("Active", ViewData["Active"] != null ? ViewData["Active"] : (ViewData.Model.Active != null ? ViewData.Model.Active : false)
you can forget the fluff if you like:
如果你愿意,你可以忘记绒毛:
=Html.CheckBox("Active", ViewData.Model.Active)
..causes the same problem.
..引发同样的问题。
when i try to update my model with:
当我尝试更新我的模型时:
UpdateModel(vacancy, Request.Form.AllKeys);
..i get the object array return with two bool fields. ok, so i understand the need for the hidden field. but im using MVC Beta and i believe the post data is not being processed by UpdateModel correctly. i get this error: System.FormatException "String was not recognized as a valid Boolean." ..when the form posts back sometimes. What i mean by that is that the form works fine, saving true and false states, except when another field on the form is empty. then it complains about the "true,false" value. and thats fine. i understand that a string "true,false" is not a valid bool but y does it complain sometimes and other times work? pls help
..i获取具有两个bool字段的对象数组返回。好的,所以我理解隐藏领域的必要性。但我使用MVC Beta,我相信UpdateModel没有正确处理帖子数据。我收到此错误:System.FormatException“字符串未被识别为有效的布尔值。” ..当表格有时发回。我的意思是表单工作正常,保存真实和虚假状态,除非表单上的另一个字段为空。然后它抱怨“真实,虚假”的价值。那没关系。我明白一个字符串“true,false”不是一个有效的bool但是y有时会抱怨并且其他时间有效吗?请帮助
EDIT: please, if some1 can even suggest another approach to the UpdateModel() method, i'll look at that. i suspect tho that this is something simple i'm missing.
编辑:请,如果some1甚至可以建议另一种方法的UpdateModel()方法,我会看看。我怀疑这是我想念的简单事情。
EDIT 2: this seems to be a known bug in MVC Beta (http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=2671&FocusElement=CommentTextBox). can anyone suggest a workaround?
编辑2:这似乎是在MVC的测试(http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=2671&FocusElement=CommentTextBox)一个已知的bug。任何人都可以建议解决方法?
1 个解决方案
#1
1
Solved in ASP.net MVC 1.0
在ASP.net MVC 1.0中解决
(added the answer so we can eliminate the question from Unanswered
)
(添加了答案,以便我们可以消除未回复的问题)
#1
1
Solved in ASP.net MVC 1.0
在ASP.net MVC 1.0中解决
(added the answer so we can eliminate the question from Unanswered
)
(添加了答案,以便我们可以消除未回复的问题)