Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

143
Vistas
Call two actions from Html.BeginForm ASP.NET MVC

So the first action would be:

@using (Html.BeginForm("Edit", "Post", FormMethod.Post, new { enctype = "multipart/form-data" }))

and the second would be a ajax call:

<input type="submit" value="Save" onclick="deleteImages()" class="btn btn-default" />

Ajax:

<script>
    let deletedImages = [];
    function Remove(id, e) {
        deletedImages.push(id);
        console.log(deletedImages);
        $(e).fadeOut(1000);
        $(e).next().fadeOut(1000);
    }

//starts here

    function deleteImages() {
    $.ajax({
        type: 'POST',
        url: "@Url.Action("DeleteImages", "Image")",
        data: { "deletedImages": deletedImages },
        success: function(data) {
            alert("deleted");
        },
        error: function(data) {
            window.location.reload();
        }
    });
    }
</script>

Only the onClick function is getting called, whereas the Post/Edit of the Html.BeginForm is not. Any suggestions on how to fix this?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

you can use onsubmit. run onsubmit before post

@using (Html.BeginForm("Edit", "Post", FormMethod.Post, new
{ onsubmit="deleteImages()", enctype = "multipart/form-data" }))

second option: (using jquery)

$('form').submit(function() {
   deleteImages();
   return true;
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

@using (Html.BeginForm("Edit", "Post", FormMethod.Post, new { enctype = "multipart/form-data" }))

Maybe you are missing Area?

Something like

@using (Html.BeginForm("Edit", "Post", new { area = "" }, FormMethod.Post, new { enctype = "multipart/form-data" }))

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda