I work with asp.net mvc and devextreme I have model with bool value and I will add form in the view
my problem is when I uncheck the checkbox I got a validation message the checkForImges field is required
I want to remove it and the red border
view code
@model ArchiveConfigManager.Models.QueryRetrieve
@using DevExtreme.AspNet.Mvc
@(Html.DevExtreme().Form().ID("form")
.ShowValidationSummary(false).ShowRequiredMark(false).
ShowOptionalMark(false).
ShowColonAfterLabel(false)
.ColCount(1)
.Items(items =>
{
items.AddGroup()
.Items(groupItems =>
{
groupItems.AddSimple().DataField("CheckForImages").
IsRequired(false).Label(l => l.Visible(false)).
Editor(e => e.CheckBox().Text("Check For Images"))
;})
;})
.FormData(Model)
)
model code
public class QueryRetrieve
{
public bool CheckForImages { set; get; }
}
The ASP.NET framework considers any non-nullable properties as required. So, to avoid the issue you can mark your CheckForImages property as nullable:
public class QueryRetrieve
{
public bool? CheckForImages { set; get; }
}