Here is what I do to update some information about page elements:
Im my view Practice .ascx, I have a set of practice for updating
<div style=" width:20%; float:right; background-color:inherit" > (Last Seen: <span id="<%: practice.ID %>LastSeenPractice" class="LastSeenPractice" >Loading...</span>) </div>
Also in Practices.ascx in the jQuery scripting section to update practice, I do this every 10 minutes:
function UpdatePractice() { jQuery.post("/reporter/LastSeenPractice", $.param({ practiceID: pid, doctorIDs: DoctorIDs }, true), UpdateLastSeenPractice, "json"); } setInterval(UpdatePractice, 1000*60*10)
In your controller, create a function to receive a jquery call:
[HttpPost] public JsonResult LastSeenPractice(string practiceID, List<String> doctorIDs) { ... process query ... return Json(new { pid = practiceID, LastSeenPractice = lastSeenPractice, LastSeenDoctor = lastSeenDoctor }); }
and finally back to jscript, create a callback function to handle the json result
function UpdateLastSeenPractice(data) { $("#" + data.pid + " .LastSeenPractice").html(data.LastSeenPractice); for (var key in data.LastSeenDoctor) { $("#" + key + " .LastSeenDoctor").html(data.LastSeenDoctor[key]); } };
and this should be the main thread of making an ajax call using jQuery
Update: I forgot about partial viewing of part of the question. I use nested partial views to reduce the complexity of already complex syntax. Each of my practices is under its own view, and index.ascx goes through all the methods and creates a partial view in treenode and passes a parameter (unfortunately, u can only pass one of them, so I set all the settings necessary for the partial view in dictionary, therefore, PracticesDict:
<div id="bodyPracticesList" style="float:left; width:100%"> <% Html.RenderPartial("Practices", Model.PracticesDict); %> </div>
All my scripts are in index.aspx, and html is in practice.ascx, so you can do something similar with your three forms, that is, put them in partial views, as Max suggested breaking things.