Почему только один выпадающий список не работает после проверки?Невозможно сохранить выбранное мной значение.(Раскрывающийся список IndustryType).Раскрывающийся список, как показано ниже:
@Html.ExtLabelFor(model => model.Customer.SoldToAddress.IndustryType, htmlAttributes: new { pad = 4, @class = "control-label col-4" })
Это обязательное поле, определенное в модели как [Обязательное].
Я пытался удалить
@Html.ValidationMessageFor(model => model.Customer.SoldToAddress.IndustryType, "", new { @class = "text-danger" })
, но оновсе еще не сохраняет.
Остальные работают очень хорошо, например:
@(Html.Kendo().DropDownListFor(model => model.Customer.SoldToAddress.Country)
Мой взгляд:
@model FAPL.eBAP.Service.Model.CustomerModel
@using FAPL.eBAP.Data.Enums;
@using FAPL.eBAP.Service;
<style>
.k-widget.k-tooltip-validation {
background: #dc3545;
color: #f1e7d1 !important;
}
.col-2 {
max-width: 13%;
}
.col-3, .col-sm-3 {
padding-right: 12px;
}
</style>
<div class="SoldTo">
<div class="row">
<div class="col-6">
@Html.HiddenFor(model => model.Customer.SoldToAddress.AddressID)
<div class="form-group row">
@Html.ExtLabelFor(model => model.Customer.SoldToAddress.IndustryType, htmlAttributes: new { pad = 4, @class = "control-label col-4" })
<div class="col-sm-6">
@(Html.Kendo().DropDownListFor(model => model.Customer.SoldToAddress.IndustryType).Filter(FilterType.Contains)
.HtmlAttributes(new { data_value_primitive = true })
.DataTextField("Text")
.DataValueField("Value")
.BindTo((System.Collections.IEnumerable)ViewData[Constants.LookupKey.Industry])
.OptionLabel("Please Select")
.Enable(Model.accessRights.SoldTo)
)
@Html.ValidationMessageFor(model => model.Customer.SoldToAddress.IndustryType, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group row">
@Html.LabelFor(model => model.Customer.SoldToAddress.JOCFlag, htmlAttributes: new { pad = 4, @class = "control-label col-4" })
<div class="col-sm-6">
@(Html.Kendo().DropDownListFor(model => model.Customer.SoldToAddress.JOCFlag)
.Filter(FilterType.Contains)
.HtmlAttributes(new { data_value_primitive = true })
.DataTextField("Text")
.DataValueField("Value")
.BindTo(EnumHelper.GetSelectList(typeof(JOCFlag)).OrderBy(x => x.Text))
.OptionLabel("Please Select ...")
.Enable(Model.accessRights.SoldTo)
)
</div>
</div>
@Html.EditorFor(model => model.Customer.SoldToAddress.HouseNo, new { max = 10, pad = 4, enable = Model.accessRights.SoldTo, specialPad = "col-sm-6" })
@Html.EditorFor(model => model.Customer.SoldToAddress.Address1, new { max = 60, pad = 4, enable = Model.accessRights.SoldTo, template = "width:230%", specialPad = "col-sm-6" })
@Html.EditorFor(model => model.Customer.SoldToAddress.Address2, new { max = 60, pad = 4, enable = Model.accessRights.SoldTo, template = "width:230%", specialPad = "col-sm-6" })
@Html.EditorFor(model => model.Customer.SoldToAddress.PostalCode, new { max = 20, pad = 4, enable = Model.accessRights.SoldTo, specialPad = "col-sm-6" })
</div>
</div>
<div class="row">
<div class="col-6">
@Html.EditorFor(model => model.Customer.SoldToAddress.City, new { max = 40, pad = 4, enable = Model.accessRights.SoldTo, specialPad = "col-sm-7" })
@Html.EditorFor(model => model.Customer.SoldToAddress.Telephone, new { pad = 4, enable = Model.accessRights.SoldTo, specialPad = "col-sm-7" })
@Html.EditorFor(model => model.Customer.SoldToAddress.Fax, new { pad = 4, enable = Model.accessRights.SoldTo, specialPad = "col-sm-7" })
</div>
<div class="col-5">
<div class="form-group row">
@Html.LabelFor(model => model.Customer.SoldToAddress.Country, htmlAttributes: new { pad = 4, @class = "control-label col-4" })
<div class="col-sm-6">
@(Html.Kendo().DropDownListFor(model => model.Customer.SoldToAddress.Country)
.Filter(FilterType.Contains)
.HtmlAttributes(new { data_value_primitive = true })
.DataTextField("Text")
.DataValueField("Value")
.BindTo((System.Collections.IEnumerable)ViewData[Constants.LookupKey.Country])
.OptionLabel("Please Select ...")
.Enable(Model.accessRights.SoldTo)
)
</div>
</div>
@Html.EditorFor(model => model.Customer.SoldToAddress.Mobile, new { pad = 4, enable = Model.accessRights.SoldTo, specialPad = "col-sm-7" })
@Html.EditorFor(model => model.Customer.SoldToAddress.Email, "String", new { pad = 4, enable = Model.accessRights.SoldTo, specialPad = "col-sm-7" })
</div>
</div>
</div>
@Html.HiddenFor(model => model.Customer.SoldToAddress.AddressID)
@Html.HiddenFor(model => model.Customer.SoldToAddress.HouseNo)
@Html.HiddenFor(model => model.Customer.SoldToAddress.Address1)
@Html.HiddenFor(model => model.Customer.SoldToAddress.Address2)
@Html.HiddenFor(model => model.Customer.SoldToAddress.PostalCode)
@Html.HiddenFor(model => model.Customer.SoldToAddress.City)
@Html.HiddenFor(model => model.Customer.SoldToAddress.Telephone)
@Html.HiddenFor(model => model.Customer.SoldToAddress.Fax)
@Html.HiddenFor(model => model.Customer.SoldToAddress.Country)
@Html.HiddenFor(model => model.Customer.SoldToAddress.Mobile)
@Html.HiddenFor(model => model.Customer.SoldToAddress.Email)
@Html.HiddenFor(model => model.Customer.SoldToAddress.JOCFlag)
@Html.HiddenFor(model => model.Customer.SoldToAddress.IndustryType)
@Html.HiddenFor(model => model.Customer.SoldToAddress.UpdatedBy)
@Html.HiddenFor(model => model.Customer.SoldToAddress.UpdatedDate)
@Html.HiddenFor(model => model.Customer.SoldToAddress.CreatedBy)
@Html.HiddenFor(model => model.Customer.SoldToAddress.CreatedDate)
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")"></script>
<script type="text/javascript">
$.validator.setDefaults({
ignore: ""
});
</script>