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

74
Views
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 answers
Answer question

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