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 7446353
In Process

The Archive Base Latest Questions

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

In my MVC 3 app I am using CKeditor for editing rich text. Right

  • 0

In my MVC 3 app I am using CKeditor for editing rich text. Right now I need to be able to save text to DB with HTML tags.

Problem is that on my click of button ‘Save’ nothing happens.

Alert returns Undefined.

View:

@using (Html.BeginForm()) {
    @Html.ValidationSummary(true)
    <fieldset>
        @Html.DropDownListFor(model=>model.Id, Model.Texts)  
        <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_data1 = $('editor1').val(); 
            var editor_data = editor_data1.getHtml();
            var url = '@Url.Action("EditText", "Admin")';
            var data = { commentText: editor_data };

            function Save() {
                alert(editor_data);
                $.post(url, data, function(result) {  

});

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

//                        var textSelect = $('#Text');
//                        textSelect.empty();
//                        $("#Text")[0].value = text;
                        CKEDITOR.instances['editor1'].setData(text);
                        //                $.each(text, function (index, employee) {
                        //                    textSelect.append($('<option/>', {
                        //                        value: employee.Value,
                        //                        text: employee.Text
                        ////                    }));
                        //                });
                    });

                }
            });
</script>
    </fieldset>
     <p>
            <input type="button" value="Save"  onclick="Save()"/>
        </p>
} 
  • 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:17:30+00:00Added an answer on May 29, 2026 at 12:17 pm

    Try replacing:

    var editor_data1 = $('editor1').val();
    

    with:

    var editor_data1 = $('#editor1').val();
    

    in jQuery if you want to perform an id selector you should prefix it with #.

    Also the .val() method that you are using returns a string. I am not aware with CKEditor but I very highly doubt that there is a getHtml on the string type.

    You probably meant:

    var editor_data = CKEDITOR.instances['editor1'].getData();
    

    Also you seem to be subscribing to the change event of some DOM element with id="Id":

    $('#Id').change(...);
    

    I can’t see any such element in your DOM. Are you sure that you didn’t mean:

    $('#editor1').change(...);
    

    or some other element? Maybe the dropdown?

    You seem to have some issues with the jQuery syntax. I would recommend you going through some tutorials.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using CKeditor in MVC 3 app. Right now i am in need
I am trying to create a web site app using MVC 3- The problem
I deployed an ASP.NET MVC app using MSDeploy and ran into this problem i
I have an ASP.Net-MVC app using LinqToSql. I have a subcontracts table, a service_lines
I have a MVC app and using JQuery. I have anchor that I setup
I'm writing an app using asp.net-mvc deploying to iis6. I'm using forms authentication. Usually
If we develop a winform app using an MVC architecture, it should not be
I am using the standard outputcache tag in my MVC app which works great
I am using Master Pages in an ASP.NET MVC app that lets you submit
I'm using IIRF on IIS6/Server03 with an MVC app in the root of the

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.