Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
Set maxlength on TextEditor
posted

I have an Asp.net MVC/Razor app using the Infragistics JQuery controls and I would like to limit the number of characters entered in a igTextEditor. On my page I have

@(Html.Infragistics().TextEditorFor(m=>m.Name).ID("assemblyNameEditor").ValidatorOptions(m=>m.OnBlur(true).OnSubmit(true).FormSubmit(true).KeepFocus(ValidatorKeepFocus.Once)).Required(true)

and then down in my JQuery script section I have

$("#assemblyNameEditor").igTextEditor("option", "maxLength", 10);

when looking at the rendered page I see that the maxlength attribute was not added. SO then I just used simple jquery to add the maxlength attribute ...

$("#assemblyNameEditor").attr("maxLength", 10);

which rendered fine but for some reason was still not limiting the characters.

So then I was I hoping I could at least decorate my model with DataAnnotations such as

[StringLength(20, ErrorMessage = "Must be under 20 characters")]

and have have validation catch it on submit, but that didn't work either.

Not sure what else to try??

Parents
  • 7499
    posted

    Hello Mlangowski,

    Have you tried setting the maxlength of the texteditor something like below, I was able to limit the characters in the editor using the following code

    @(Html.Infragistics().TextEditor()

    .ID("textEditor")

    .MaxLength(10)

    .Width(200)

    .NullText("Enter Text")

    .Render())


    Please let me know if you have any further questions regarding this matter.

Reply Children