We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

How to make Data annotations to work with RTE

To use data annotations with RTE, kindly ensure the following steps:

   

Step 1:  Add necessary scripts and theme files for RTE and validation to work properly in the _Layout.cshtml.

 

 

Step 2: Enable client validation and unobtrusive JavaScript in the web.config file.   

 

Step 3: Add a model class and make sure to include “AllowHtml” attribute for the RTE’s field to allow HTML content to be posted to the controller. 

 

Step 4: Add a form with the RTEFor control. Include the label and validation message placeholders for RTE control.   

 

Step 5: Add script to modify the validator settings and include the hidden fields in validation. Since RTE uses hidden <textarea> element to store its content.  

 

Step 6: Add an Action method in the controller to handle the form post. You can retrieve the RTE’s content from the model.   

 

Sample

Article ID: Published Date: Last Revised Date: Platform: Control:
8942 07/11/2018 07/11/2018 ASP.NET MVC RichTextEditor
Did you find this information helpful?
Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.