Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7447745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:42:59+00:00 2026-05-29T12:42:59+00:00

I am using CKeditor in MVC 3 app. Right now i am in need

  • 0

I am using CKeditor in MVC 3 app.

Right now i am in need of saving text with HTML tags to DB, problem is that Ckeditors GetData() method returns raw format of data (http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.editor.html#getData)

I need a way to make that raw format to normal string with Html tags

View :

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>TextEditionViewModel</legend>


        @Html.DropDownListFor(model=>model.Id, Model.Texts)
        <div class="editor-label">
            @Html.LabelFor(model => model.Text)
        </div>
        <div class="editor-field">

            @Html.TextAreaFor((model => model.Text), new { @Id = "editor1" })
            @Html.ValidationMessageFor(model => model.Text)
        </div>

        <script type="text/javascript">
            CKEDITOR.replace('editor1');
            </script>


        <script type="text/javascript">

            var editor_data = CKEDITOR.instances['editor1'].getData();
            var url = '@Url.Action("EditText1", "Admin")';
            var data = { CommentText: editor_data };

            function Save() {
               alert(editor_data);
                $.post(url, { CommentText: editor_data }, function (result) {

                });

            };

            $('#Id').change(function () {
                var selectedText = $(this).val();
                if (selectedText != null && selectedText != '') {
                    $.getJSON('@Url.Action("Text","Admin")', { Id: selectedText }, function (text) {
                        CKEDITOR.instances['editor1'].setData(text);

                    });

                }
            });
</script>
    </fieldset>
     <p>
            <input type="button" value="Save"  onclick="Save()"/>
        </p>
}

If editor_data is set to Normal “Text” string everything works!

Controller

    public ActionResult EditText1(String CommentText)
    {

        return null;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:43:01+00:00Added an answer on May 29, 2026 at 12:43 pm

    You could decorate your controller action with the [ValidateInput] attribute to allow POSTing HTML tags which is not authorized by ASP.NET by default:

    [HttpPost]
    [ValidateInput(false)]
    public ActionResult EditText1(string commentText)
    {
        return null;
    }
    

    UPDATE:

    The problem is related to the fact that the editor_data variable is not accessible in the Save method.

    You could do this:

    <script type="text/javascript">
        function Save() {
            var editor_data = CKEDITOR.instances['editor1'].getData();
            var url = '@Url.Action("EditText1", "Admin")';
            var data = { CommentText: editor_data };
            $.post(url, data, function (result) {
    
            });
        }
    
        ...
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my MVC 3 app I am using CKeditor for editing rich text. Right
I am using CKEditor for my asp.net mvc (C#) application. I need to extract
I am using ckeditor in drupal and add some html tags in it like
All, I'm very successfully using CKEditor in my app that allows clients to build
I have an ASP.NET MVC application and I'm using CKEditor for text entry. I
I am creating an editor in asp.net MVC application using ckeditor. In textarea i
Using ASP.NET MVC there are situations (such as form submission) that may require a
I'm using CKEditor for a Content Management System. When someone edits the text on
Greetings, I'm trying to prevent XSS and improper html from input fields using CKEditor
In my MVC 3 application i need to be able to edit text with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.