In my Ext Js3 application I created a form with a checkbox with the following code:
}, {
xtype: 'checkbox',
fieldLabel: 'Is Automation Failure',
inputValue: 'true',
name: 'isAutomationFailure'
}, {
When I check the checkbox it correctly sends isAutomationFailure: true to my Asp.NET MVC action, and life is good. However, if I leave the checkbox unchecked, it gives:
The parameters dictionary contains a null entry for parameter ‘isAutomationFailure’ of non-nullable type ‘System.Boolean’ for method
I understand that checkboxes do not send anything over if a checkbox isn’t checked, but I was under the impression that a non-specified bool would default to false if not specified. My action has the following signature:
public virtual JsonResult SetTestRunFailureInfo(int runId, bool isAutomationFailure, int? tfsWorkitemId)
How can I get this to work (without having to resort to turning the parameter into a nullable type)?
Change your
booltobool?and treatnullasfalse. That’s a “feature” of Ext JS.