gpt4 book ai didi

c# - Kendo Combobox 未触发所需的验证消息

转载 作者:太空宇宙 更新时间:2023-11-03 22:58:55 26 4
gpt4 key购买 nike

我已经为我的 MVC View 实现了必需的验证。文本控件显示验证消息,但剑道组合框不显示。我正在做一个ajax回发。

组合框不显示消息的任何原因?工作类型组合是强制性的,但它不显示验证消息。

enter image description here

查看

@using (Ajax.BeginForm("ActivityWorkLog_Create", "Activity", new AjaxOptions
{
HttpMethod = "POST",
OnSuccess = "OnWorklogStatusSuccess",
OnFailure = "OnWorklogStatusFailure"
}, new { id = "workLogForm" }))
{

<div class="k-popup-edit-form k-window-content k-content" data-role="window">
<div class="k-edit-form-container">
@Html.HiddenFor(x => x.RequestID, new { data_bind = "value: requestId" })
@Html.HiddenFor(x => x.ActivityID, new { data_bind = "value: activityId" })
@Html.HiddenFor(x => x.CountryCode, new { data_bind = "value: countryCode" })

<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.WorkLogAppliesToName)
</div>
<div class="editor-field">
@(Html.Kendo().ComboBoxFor(model => model.WorkLogAppliesToName)
.Name("WorkLogAppliesToID")
.Filter("contains")
.HtmlAttributes(new { style = "width:300px", @readonly = "readonly" })
.Placeholder("Select...")
.DataTextField("WorkLogAppliesToName")
.DataValueField("WorkLogAppliesToID")

.DataSource(dataSource => dataSource
.Read(read => read.Action("GetWorkLogAppliesTo", "WorkLog", new { id = 0 }).Type(HttpVerbs.Post)
)

)
)
@Html.ValidationMessageFor(model => model.WorkLogAppliesToName, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.ActivitySLA)
</div>
<div class="editor-field">
@*@Html.EditorFor(model => model.ActivitySLA)*@
@Html.TextBoxFor(model => model.ActivitySLA, new { id = "ActivityDesc", @readonly = "readonly", Class = "textBoxFor" })

</div>
</div>

<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.ActivityID)
</div>
<div class="editor-field">
@(Html.Kendo().ComboBoxFor(model => model.ActivityID)
.Name("Activity")
.Filter("contains")
.HtmlAttributes(new { style = "width:300px", @readonly = "readonly" })
.Placeholder("Select...")
.DataTextField("Description")
.DataValueField("ActivityID")

.DataSource(dataSource => dataSource
.Read(read => read.Action("GetActivity", "WorkLog").Data("additionalActivityInfo").Type(HttpVerbs.Post)
)//.ServerFiltering(true)
)//.CascadeFrom("ServiceID").Filter("contains")

)
@Html.ValidationMessageFor(model => model.ServiceID, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.WorkLogType)
</div>
<div class="editor-field">
@(Html.Kendo().ComboBoxFor(model => model.WorkLogTypeCode)
.Name("WorkLogTypeCode1")
.Filter("contains")
.HtmlAttributes(new { style = "width:300px"})
.Placeholder("Select...")
.DataTextField("WorkLogType")
.DataValueField("WorkLogTypeCode")
.DataSource(dataSource => dataSource
.Read(read => read.Action("GetWorkLogType", "WorkLog").Data("additionalWLTInfo").Type(HttpVerbs.Post))
)

)
@Html.ValidationMessageFor(model => model.WorkLogTypeCode, "Please select a worklog type", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.WorkLogSubject)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.WorkLogSubject)
@Html.ValidationMessageFor(model => model.WorkLogSubject, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="editor-label">
@Html.LabelFor(model => model.WorkLogDetails)
</div>
<div class="editor-field">
@Html.TextAreaFor(model => model.WorkLogDetails, new { htmlAttributes = new { @class = "form-control", cols = "50" } })
@Html.ValidationMessageFor(model => model.WorkLogDetails, "", new { @class = "text-danger" })
</div>
</div>

<div class="worklogStatusButtonAlign">
<button id="btnWorkLogSave" type="submit" class="k-button k-button-icontext k-primary k-grid-update">Save</button>
<button id="btnClose" type="button" class="k-button k-button-icontext k-grid-cancel">Cancel</button>

</div>

<div id="worklogStatusMessage"> </div>

</div>
</div>
}

Javascript

   <script>

$(document).ready(function () {



var form = $("#workLogForm")
.removeData("validator")
.removeData("unobtrusiveValidation");
$.validator.unobtrusive.parse(form);


});

查看模型

 public class ActivityWorkLogViewModel
{
[ScaffoldColumn(false)]
[Display(Name = "WorkLogID", ResourceType = typeof(Resources.Resource))]
public int WorkLogID { get; set; }

[Required(ErrorMessage = "WorkLogType is required")]
[Display(Name = "WorkLogTypeCode", ResourceType = typeof(Resources.Resource))]
public string WorkLogTypeCode { get; set; }


[Display(Name = "WorkLogType", ResourceType = typeof(Resources.Resource))]
public string WorkLogType { get; set; }
[Required]
[Display(Name = "WorkLogAppliesToID", ResourceType = typeof(Resources.Resource))]
public int WorkLogAppliesToID { get; set; }
[Display(Name = "WorkLogAppliesToName", ResourceType = typeof(Resources.Resource))]
public string WorkLogAppliesToName { get; set; }
[Required]
[Display(Name = "RequestID", ResourceType = typeof(Resources.Resource))]
public int RequestID { get; set; }
[Display(Name = "ServiceID", ResourceType = typeof(Resources.Resource))]
public Nullable<int> ServiceID { get; set; }
[Display(Name = "ActivityID", ResourceType = typeof(Resources.Resource))]
public Nullable<int> ActivityID { get; set; }
[Required(ErrorMessage = "Subject is required")]
[Display(Name = "WorkLogSubject", ResourceType = typeof(Resources.Resource))]
public string WorkLogSubject { get; set; }
[Required(ErrorMessage = "Details is required")]
[Display(Name = "WorkLogDetails", ResourceType = typeof(Resources.Resource))]
public string WorkLogDetails { get; set; }
[Display(Name = "EmailTo", ResourceType = typeof(Resources.Resource))]
public string EmailTo { get; set; }
[Display(Name = "IsActive", ResourceType = typeof(Resources.Resource))]
public bool IsActive { get; set; }
[Display(Name = "CountryCode", ResourceType = typeof(Resources.Resource))]
public string CountryCode { get; set; }
[Display(Name = "ActivitySLA", ResourceType = typeof(Resources.Resource))]
public string ActivitySLA { get; set; }
}

最佳答案

尝试添加这个:

<script>
$(function () {
$("form").kendoValidator();
});
</script>

和/或:

<script>
$.validator.setDefaults({
ignore: ""
});
</script>

关于c# - Kendo Combobox 未触发所需的验证消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44072259/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com