Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

75
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda