我使用 asp.net mvc 和 devextreme 我有带有 bool 值的模型,我将在 View 中添加表单
我的问题是,当我取消选中该复选框时,我收到一条验证消息,需要 checkForImges 字段
我想删除它和红色边框
查看代码
@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)
)
型号代码
public class QueryRetrieve
{
public bool CheckForImages { set; get; }
}
最佳答案
ASP.NET 框架根据需要考虑任何不可为 null 的属性。因此,为了避免出现此问题,您可以将 CheckForImages 属性标记为可为空:
public class QueryRetrieve
{
public bool? CheckForImages { set; get; }
}
关于asp.net-mvc - 从 devextreme 表单中删除必需的字段值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56169139/