Asp.net MVC jquery-ajax dont render html

Posted by Troublesum on Stack Overflow See other posts from Stack Overflow or by Troublesum
Published on 2010-03-16T11:09:15Z Indexed on 2010/03/16 11:26 UTC
Read the original article Hit count: 269

Filed under:
|

Hi, Im trying to use jqeury ajax with MVC i can get it to post back to the action i want and it returns the ViewData objects with updated Data but never renders the HTML. I have i View which contains some MVC User Controls and i want them to update on a timer.

Here is my View Markup

  <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/PageWithSummaryViewAndTabs.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="FullCaseTitle" ContentPlaceHolderID="TitleContent" runat="server">

</asp:Content>

<asp:Content ID="FullCaseContent" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
window.setInterval(test, 5000);
function test() {
    jQuery.get("/PatientCase/RefreshEPRF", function(response) { });
}
</script>

<div id="loadingDiv" style="display:none">Updating</div>

   <input id="refreshPatientCaseIndexButton" type="submit" visible="true" title="refresh" value="Refresh" />
    <h2>Full Case</h2>
    <div id="EPRFContent"> 
<%Html.RenderPartial(@"~/Views/PatientCase/SectionEPRF.ascx"); %>
<%Html.RenderPartial(@"~/Views/PatientCase/SectionDrugs.ascx"); %>
       </div>
               <div id="ImageContent"> 

<%Html.RenderPartial(@"~/Views/PatientCase/SectionImagery.ascx"); %>

On postback i call a Action Called RefreshEPRF which loads just the required user controls again

    <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%Html.RenderPartial(@"~/Views/PatientCase/SectionEPRF.ascx"); %>
<%Html.RenderPartial(@"~/Views/PatientCase/SectionDrugs.ascx"); %>

And finaly the marpup in the control

    <table id="detailstable">
<tr><td id="detailslablecolumn">Patient Name : </td><td>
<%
foreach (var item in (List<STS_Lite.Models.PatinetCase.EPRFItem>)ViewData["EPRF"])
{
if (item.datumItemId == 46)
{
if (item.Stroke)
{
%>
<img src="/PatientCaseIndex/InkImageData/GetInkImage/<%=ViewData["PatientCaseId"]%>/<%=ViewData["TemplateInstanceId"]%>/<%=item.TemplateItemId %>" />
<%
}
else
{%>
<%=item.Value.ToString()%>
<%} 
break;
}
} 
%></td></tr><table>

When i step through this code the ViewData in the user control has the new updated values but the page comes back with no new values. I have tried the jquery.get and ajax but with no luck. Any help would be great thanks

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about jquery-ajax