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

77
Vistas
How to call a same parial view on button click in MVC with java script

I need to call a same view on button click. Actually i need to refresh a view on button click.

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

0

You can try like below:

Controller:

   public class PartialController : Controller
    {
        public IActionResult PartialViewFromButtonClick()
        {
            return PartialView("_PartialViewFromBtnClick");
        }
    }

Partial View Sample:

<h4>Load Partial View</h4>



<style>
    table {
        font-family: arial, sans-serif;
        border-collapse: collapse;
        width: 100%;
    }

    td, th {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
    }

    tr:nth-child(even) {
        background-color: #dddddd;
    }
</style>

<div>
    <table class="table-bordered ">
        <tr>
            <td><strong>Search</strong></td>
            <td>
                <input type="text" name="searchkey" class="form-control" placeholder="Enter Search Key" />

            </td>
            <td>

                <input type="submit" value="Search" style="font-weight: bold;" />
            </td>
        </tr>


    </table>
</div>
<br />

The View Where You Like To Load The Partial View:

HTML:

 <div>
        <button id="btnLoadPartialView" class="btn btn-primary">Load Partial View</button>
 </div>

<div id="loadPartailView">

</div>

Script:

@section scripts {
    <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script>
    <script>
        $(document).ready(function () {
            $("#btnLoadPartialView").click(function () {
                $("#loadPartailView").load("/Partial/PartialViewFromButtonClick");
            });
        });
    </script>
}

Output:

enter image description here

Note: If you would like to laod partial view with parameter you could try like this $('#loadPartailView').load('/PartialController/PartialViewFromButtonClick?parameter=2095'); Additionally each time when you would load the partial view in this fashion it will autometically refresh the partial view itself. No additional things to implement.

Hope it would help you.

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