Note that there are some explanatory texts on larger screens.

plurals
  1. POstrongly-typed partial views MVC RC1
    text
    copied!<p>having a problem passing ViewData.Model to the partial views. It always is defaulting to null even if I equate it to a result query. I cannot access the strongly typed data because the Model is null. My current code is this, </p> <p>ViewPage</p> <pre><code>&lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"&gt; &lt;% Html.RenderPartial("header", this.ViewData.Model); %&gt; &lt;% Html.RenderPartial("test", this.ViewData.Model); %&gt; &lt;div id="userControls"&gt; &lt;/div&gt; &lt;/asp:Content&gt; </code></pre> <p>UserControl - header</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;testMVCProject.Models.information&gt;" %&gt; &lt;h2&gt; ACReport&lt;/h2&gt; &lt;p&gt; id: &lt;%= Html.Encode(Model.id) %&gt; &lt;/p&gt; &lt;p&gt; type: &lt;%= Html.Encode(Model.type) %&gt; &lt;/p&gt; </code></pre> <p>UserControl - test</p> <pre><code>&lt;%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl&lt;testMVCProject.Models.information&gt;" %&gt; &lt;% using (Ajax.BeginForm( "pressureV2", "Home", new { id = ViewData.Model.id }, new AjaxOptions { UpdateTargetId = "userControls", HttpMethod = "GET" }, new { @id = "genInfoLinkForm" })) {%&gt; &lt;%= Html.SubmitButton("hey", "Lol") %&gt; &lt;%} %&gt; </code></pre> <p>Controller</p> <pre><code>public ActionResult header(int id) { var headerResults = from c in db.information where c.id == id select new information { id = c.id, type = c.type }; ViewData.Model = headerResults.FirstOrDefault(); return View(ViewData.Model); } public ActionResult pressureV2(int id) { var pressureVResults = from c in db.pressure_volume_tests where c.id == id select new pressureVT { bottomCVP = c.bottom_CVP, topCVP = c.top_CVP }; ViewData.Model = pressureVResults.FirstOrDefault(); return View(ViewData.Model); } </code></pre>
 

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