I have a partial view that loads into modal jQuery in asp.net MVC 3. The problem is that the view is not refreshing properly. Here is the order of events:
1) The main view has a table listing the records of various events. Each line of the table has a link to show detailed information about the event. 2) When a link to this table is clicked, a partial view is loaded into a modal view.
In some cases, this works great; in other cases, the model takes a very long time to load. After closing the partial view / modal and clicking on another link from the table on the main view, the partial view will load showing the data from the previous loaded file. It does not refresh correctly.
Definition of modality on the main screen: Download, please wait ...
<script type="text/javascript"> $(document).ready(function () { $("#EventRegistrantSummary").dialog({ bgiframe: true, autoOpen: false, height: 500, width: 980, resizable: false, modal: true }); }); function showEventRegistrantSummary(id) { $.get("/Event/EventRegistrantSummary/" + id, function (data) { $("#EventRegistrantSummary").html(data); }); $("#EventRegistrantSummary").dialog('open'); return false; } </script>
Controller:
public PartialViewResult EventRegistrantSummary(Guid id) { ModelState.Clear(); Event e = db.Events.Single(ev => ev.ID == id); return PartialView(e); }
Partial view:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<model.Event>" %> <% using (Ajax.BeginForm("EditUpdate", new AjaxOptions { UpdateTargetId="Target", InsertionMode= InsertionMode.Replace})) {%> <h6 style="text-align:center">Registration Summary: <%= Model.Name %></h6> <div style="float:left;width:35%"> <fieldset id="Overview"> <legend>Overview</legend> <div class="editor-label"> Total Registrants: <%= Model.BoatEventRegistrations.Count() %> </div> </fieldset> </div> <% } %>
Any help is greatly appreciated.
source share