I have a partial view in my application home page which displays list of rows from the database table, the data in the table gets updated every two minutes and my requirement is to display the up to date table data. I am going to achieve this with the help of jQuery SetInterval function.
The following image represents partial view which displays list of rows.

Step 1: Place partial view in a DIV.
- <Div id=”_recentfive”>
- @HTML.Partial(“_recent” , ModelObject)
- </Div>
Add the script references in the Header section of _Layout.cshtml.
- <script src="~/Scripts/jquery-1.10.2.min.js"></script>
- <script type=”text/javascript”>
- setInterval(“$(‘#_recentfive’).load(‘controllername/actionmethod’)”,2000);
- </script>
- recentfive: It is the id of DIV element where partial view is placed.
- And in the load method, mention controller name and action method which returns the model object to render in the partial view.
- 2000: It is the duration in millisecons.
- [OutputCache(NoStore=true,Location=System.Web.UI.OutputCacheLocation.Client,Duration=2)]
- Public ActionResult Youractionmethod()
- {
- . . .
- Return PartialView(“__recent”, ModelObject)
- }

Vicky ChoukseyPosted Jun 4, 2018, 12:53 AM
Nice article mate...However I am looking for some dynamic logic I have to display three element on same page having three different refresh logic. Can you pls advise
Anu VPosted Feb 23, 2017, 11:54 PM
Nice article.. Thanks
Jason UnderhillPosted Jul 14, 2015, 6:29 AM
Great post!
Manas MohapatraPosted Jul 14, 2015, 1:27 AM
Nice one...