在我的Ext Js3应用程序中,我用下面的代码创建了一个带有复选框的表单:
}, {
xtype: 'checkbox',
fieldLabel: 'Is Automation Failure',
inputValue: 'true',
name: 'isAutomationFailure'
}, {当我选中复选框时,它将isAutomationFailure: true正确地发送到我的Asp.NET MVC操作中,并且生活很好。但是,如果我不选中复选框,它会给出:
参数字典包含非空类型‘
’方法的参数'isAutomationFailure‘的空项。
据我所知,如果没有选中复选框,复选框不会发送任何内容,但我的印象是,如果没有指定,非指定的bool默认为false。我的行动有以下签名:
public virtual JsonResult SetTestRunFailureInfo(int runId, bool isAutomationFailure, int? tfsWorkitemId)如何使它工作(而不必将参数转换为可空类型)?
发布于 2011-10-21 05:37:33
将您的bool更改为bool?,并将null视为false。这是Ext的“特性”。
isAutomationFailure = isAutomationFailure ?? false;发布于 2011-10-20 20:25:30
我建议不要在复选框上使用inputValue属性。这说明了如何在表单提交:http://www.w3schools.com/jsref/prop_checkbox_value.asp上传递该值。
相反,您应该使用“检查”属性;
}, {
xtype: 'checkbox',
fieldLabel: 'Is Automation Failure',
checked: true,
name: 'isAutomationFailure'
}, {https://stackoverflow.com/questions/7840279
复制相似问题