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

194
Views
Asp.Net Core - ¿Pasar el valor del área de texto de Ckeeditor al controlador con Ajax?

Estoy usando el complemento ckeditor versión 4 ... Quiero enviar valores de ckeditot al controlador, ¡pero haga lo que haga envía un valor nulo! Busqué mucho, probé todos los métodos en el sitio, pero no funcionó :( ¿Descargué el complemento nuevamente del sitio pero aún falló?

Aviso: cuando uso "Id" en lugar de "asp-for", se envía el valor, pero necesito asp-for...

Formulario html:

 @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>

Código JavaScript:

 $(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 } }); }

Controlador :

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

Esta imagen también se genera con un punto de interrupción. ingrese la descripción de la imagen aquí

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

0

Usé este código:

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

En lugar de este código:

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

ha funcionado

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!