I am looking for a simple way to make a piece of text, which happens to be a number, on my view update in near-real-time.
I have a piece of text in my view that looks like this:
<% if (ViewData["TotalRecords"] != null)
{ %>
<%= ViewData["TotalRecords"].ToString() +
" records available to search."%>
<% } %><br />
I want ViewData["TotalRecords"] to be a constantly updating value, every 60 seconds or so.
The query underneath is:
public static string GetTotalRecords()
{
DataContext dc = new DataContext();
return dc.Records.Count().ToString("#,##0");
}
How can I make this into some kind of Ajax-enabled dynamic piece of text?
Move that part to separate action
In parent view, initially render that action with
And script with setInterval to reload TotalRecords action every 60 seconds