无法在Editor或EditorFor上显示错误消息

时间:2015-06-26 09:16:41

标签: asp.net-mvc kendo-ui editor kendo-asp.net-mvc unobtrusive-validation

在我的MVC应用程序中,我可以显示所有输入的错误消息,即TextBoxForDropdownList等。但是,通过使用相同的方法,我无法显示{{1}的验证错误}或Kendo().Editor()。我在Kendo().EditorFor()旁边尝试了ValidationMessage,但这没有任何意义。问题可能是什么?


查看:

ValidationMessageFor


以下是上面输入的生成的html代码。脚本字段与编辑器按钮相关:

<script type="text/javascript"> 
$(function () {     
    //For using Kendo Validation:
    $("form").kendoValidator();
});
</script>


//Validation works for TextBoxFor, DropDownList, etc.:
@Html.LabelFor(m => m.Summary)
@Html.TextBoxFor(m => m.Summary, new { maxlength = 50, @class = "k-textbox"})
@Html.ValidationMessageFor(m => m.Summary)

//Validation DOES NOT work for Editor or EditorFor:
@Html.LabelFor(m => m.Description, new { maxlength = 1000, @class = "editor-label" })
@(Html.Kendo().Editor()
        //@(Html.Kendo().EditorFor(m=>m.Description) //Also tried with this
        .Name("Description")
        .HtmlAttributes(new { @class = "editor-field" })
        .Resizable()
        .Tools(tools => tools
        .Clear()
        .Bold().Italic().Underline().Strikethrough().FontColor()
        .JustifyLeft()
        .JustifyCenter()
        .JustifyRight()
        .JustifyFull()
        .InsertUnorderedList().InsertOrderedList()
        .Outdent().Indent()
        .CreateLink().Unlink()
        .TableEditing()
        .CleanFormatting()
        )
)
@Html.ValidationMessage("Description")
//@Html.ValidationMessageFor(m => m.Description) //Also tried with this

更新:以下是<label for="Summary">Summary</label> <input id="Summary" class="k-textbox k-invalid" type="text" value="" style="width:660px; " name="Summary" maxlength="50" data-val-required="Required field!.." data-val="true" aria-invalid="true"> <span id="Summary_validationMessage" class="val val-danger k-invalid-msg field-validation-error" data-for="Summary" data-valmsg-for="Summary" role="alert" style="display: inline;"> <label class="editor-label" maxlength="1000" for="Description">Description</label> <table class="k-widget k-editor k-header k-editor-widget" cellspacing="4" cellpadding="0" role="presentation" style="width: 660px; height: 77px;" data-role="resizable"> <script> jQuery(function(){jQuery("#Description").kendoEditor({"resizable":true,"tools":[{"name":"bold"},{"name":"italic"},{"name":"underline"},{"name":"strikethrough"},{"name":"foreColor"}, {"name":"justifyLeft"},{"name":"justifyCenter"},{"name":"justifyRight"},{"name":"justifyFull"},{"name":"insertUnorderedList"},{"name":"insertOrderedList"},{"name":"outdent"}, {"name":"indent"},{"name":"createLink"},{"name":"unlink"},{"name":"createTable"},{"name":"addColumnLeft"},{"name":"addColumnRight"},{"name":"addRowAbove"},{"name":"addRowBelow"}, {"name":"deleteRow"},{"name":"deleteColumn"},{"name":"cleanFormatting"}); </script> <span class="field-validation-valid" data-valmsg-replace="true" data-valmsg-for="Description" style="display: none;"></span> 的呈现的html代码:

Kendo().Editor()

0 个答案:

没有答案