Note that there are some explanatory texts on larger screens.

plurals
  1. POMVC3 Nesting Partial Views with a call to Ajax.ActionLink
    primarykey
    data
    text
    <p>I am aware of the previous two questions which talk about nesting partial views but the solutions don't work for my design (which might not be the best one but I'm unsure how to adapt it).</p> <p><strong>Background</strong>:</p> <p>I collect questionnaire responses from users and store them on an sql server as xml files.</p> <p>I have a partial view which loads a table with all the Responses of a given user, this partialview populates the table with things like Response date, link to xml response document, questionnaire name, link to xml questionnaire document (the questionnaire info is pulled from a different table) and an Ajax ActionLink which redirects to action which parses the two relevant xml documents to print out Question and Answer list (i.e. visualise the response to be human readable) inside the second partial view.</p> <p>The first partial view contains a div underneath the table which I wish to populate onclick of the Ajax.ActionLink with the second partial view.</p> <p><strong>Problem</strong>: </p> <p>The answers are rendered correctly however the partial view is loaded into a whole new page, without any styling. </p> <p>The other solutions to this nesting problem use RenderPartial() however I use return PartialView()</p> <p><strong>Code</strong>:</p> <p>First Partial View:</p> <pre><code> &lt;table&gt; &lt;thead&gt; &lt;tr&gt;&lt;th&gt;headers with other info&lt;/th&gt; &lt;th&gt;Display(/th&gt; &lt;tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt;&lt;td&gt;cells with other info&lt;/td&gt; &lt;td&gt;@Ajax.ActionLink("View", "DisplayResponse","HealthStatus", new { respID = item.UniqueID,qVersion=item.QuestionnaireVersion, qname = item.QuestionnaireName }, new AjaxOptions { UpdateTargetId = "responseDisp" })&lt;/td&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;div id="responseDisp"&gt;&lt;/div&gt; &lt;--- **This is the div I wish to populate, does anyone know why it's not working?** </code></pre> <p>DisplayResponse Action (without the logic for parsing the xml documents)</p> <pre><code> public ActionResult DisplayResponse(Guid respID, int qVersion, String qname) { var allResponses = ZData.Responses; var response = (from r in allResponses where r.UniqueID == respID select r ).First(); //geting an XML questionnaire document var questionnaireDetails = ZodiacData.Questionnaires; var questionnaire = (from q in questionnaireDetails where q.Name == qname &amp;&amp; q.Version == qVersion select q ).First(); //creating XMLDocument to read the questionnaire XmlDocument xqdoc = new XmlDocument(); xqdoc.LoadXml(questionnaire.Xml); XmlElement qroot = xqdoc.DocumentElement; ViewBag.qroot = qroot; XmlDocument xrdoc = new XmlDocument(); xrdoc.LoadXml(response.Raw); XmlElement rroot = xrdoc.DocumentElement; ViewBag.rroot = rroot; return PartialView("_PrintedResponse"); } </code></pre> <p>I would be grateful for any help!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload