Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
Asp.Net Core - Pass Ckeditor textarea value to controller with Ajax?

I am using the ckeditor version 4 plugin ... I want to send ckeditot values ​​to the controller but whatever I do sends a null value!! I did a lot of searching, tried all the methods on the site, but it didn't work:( I downloaded the plugin again from the site but it still failed?

Notice: When I use "Id" instead of "asp-for", the value is sent, but I need asp-for....

Html Form :

@model Baya.Core.ViewModels.AddProductViewModel
<form id="ProductForm" method="post" enctype="multipart/form-data">
<div class="form-group">
    <label class="control-label">desc</label>
    <textarea  asp-for="Description" class="form-control"></textarea>
</div> 
<div class="modal-footer">
    <button type="button" onclick="return ValidateForm()" class="btn btn-info waves-effect">save</button>
    <button type="button" class="btn btn-danger waves-effect"
            data-dismiss="modal">
        cancel
    </button>
</div>

JavaScript Code:

$(function () {
   /* $('#Description').ckeditor();*/
    CKEDITOR.replace('Description');       
});
function ValidateForm() {       
    let Form = $("#ProductForm")[0];
    let Form_Data = new FormData(Form);
    var descProduct = CKEDITOR.instances.Description.getData();       
    Form_Data.append("Description", descProduct);
    $.ajax({
        url: '/AdminPanel/Product/AddAndUpdateProduct',
        data: Form_Data,
        contentType: false,
        processData: false,
        type: 'POST',
        success: function (data) {     
            //code
        }
    });
}

Controller :

[HttpPost]
    [ValidateAntiForgeryToken]
    public IActionResult AddAndUpdateProduct(AddProductViewModel model)
    {
    //some code
    }

This image is also output with breakpoint.. enter image description here

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I Used This Code:

CKEDITOR.instances.Description.updateElement();
var descProduct = document.getElementById('Description').value;

Instead of this code:

var descProduct = CKEDITOR.instances.Description.getData();

It's worked

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!