This is a migrated thread and some comments may be shown as answers.

Kendo Editor shows wrong error message.

3 Answers 359 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Paul Wood
Top achievements
Rank 1
Paul Wood asked on 03 Jul 2018, 05:21 AM

I use Kendo Editor in the body text for email and I don't know how to set and get error message for Kendo Editor.

I set the maximum length to 8000 for the body text and when copy and paste more than 8000 characters into it, it will show a error message "Body Text is required" which is not correct. The error should be something like "The text must be less than 8000 characters." 

Here is my code.

In Form.cshtml

<form id="email" class="hidden">
    <ul>
        <li class="k-state-active">Email</li>
        <li>Preview</li>
    </ul>
    <div>
        ......
        @Html.DecoratedField(x => x.AssignEmail.BodyText, required: true, maxLength: 8000, type: "textarea")
        ......
    </div>
    <button id="action" type="button" class="k-primary k-button">Save and Preview</button>
    <button id="backButton" type="button" class="k-button">Back to List</button>
    @Html.AntiForgeryToken()
</form>

 

In Form.chhtml.cs

[HttpPost]
        public async Task<IActionResult> OnPostAssignMail([FromQuery] int sessionId, [FromForm] AssignEmailSaveModel model)
        {
. . .  . . .
            AssignEmail = new AssignEmail()
            {
                BodyText = model.Body,
            };
. . .  . . .
        }

 

In AssignEmail.cs

namespace assign.intranetv2.Models
{
    [Table("Emails")]
    public class AssignEmail
    {
        ... ...
        [StringLength(8000)]
        [Required]
        public string BodyText { get; set; }
        ... ...
    }
}

 

In Javascript

// INIT
var bodyEditor = emailBodyKendoEditorSetup();
 
var emailBodyKendoEditorSetup = function () {
    return $('#AssignEmail_BodyText').kendoEditor().data('kendoEditor');
};

 

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 05 Jul 2018, 05:28 AM
Hello Paul,

In general, if you are just using the built-in validation provided by Razor Pages and Entity Framework, you should be able to customize the error message in the the model attribute declaration:
[Compare(nameof(Password)), ErrorMessage ="Make sure both passwords are the same")]
public string Password2 { get; set; }

Additional information on the topic can be found on MS Docs:


In addition to the above, you could also refer to the following Kendo UI Validator Demo for ASP.NET Core, where it is demonstrated how a custom validation rule and message could be set for a widget/input.

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Paul Wood
Top achievements
Rank 1
answered on 09 Jul 2018, 02:39 AM

Hi Dimitar,

Thank you for your reply.

I fixed the problem. The reason is there is a custom validation message in my code which not shown in the first post. 

As I couldn't find a way to modify this post. Could you help me to delete this post? Thanks

Regards

0
Dimitar
Telerik team
answered on 09 Jul 2018, 01:21 PM
Hi Paul,

I am glad to hear that you have managed to resolve the issue faced. Concerning the thread status - I will mark it as resolved and close it. 

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Editor
Asked by
Paul Wood
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
Paul Wood
Top achievements
Rank 1
Share this question
or