Note that there are some explanatory texts on larger screens.

plurals
  1. POForm mvc3 razor partialview post
    text
    copied!<p>I have a partialView _BasicInfoPartView associate to BasicInfoModel. This partialview contains some input and dropdownlist as:</p> <pre><code>public class BasicInfoModel { public string Name { get; set; } public string selectedRubric { get; set; } public IEnumerable&lt;SelectListItem&gt; Rubrics { get; set; } } </code></pre> <p>Partial _BasicInfoPartView.cshtml</p> <pre><code>@model ProjectZeroWebSite.Models.PleGroupModel @Html.ListBoxFor(m =&gt; m.selectedRubric, @Model.Rubrics }) @Html.TextBoxFor(m =&gt; m.Name ) </code></pre> <p>This partialview can be call in a FORM in any page. Just need to add BasicInfoModel in the page model.</p> <pre><code>public class RandomPageModel { public basicInfoModel { get; set; } public string info2{ get; set; } ... public RandomPageModel() { this.basicInfoModel = new basicInfoModel ();} } </code></pre> <p>RandomPage.cshtml</p> <pre><code>@using (Html.BeginForm()) { @Html.Partial("_BasicInfoPartView ", @Model.BasicInfoModel) @Html.TextBoxFor(m =&gt; m.info2) ... &lt;input type="submit" /&gt; } </code></pre> <p>Now the problem: I can populate the page without problem. But when I try to retrieve the information in the controller from the model: RandomPageModel.info2 OK! RandomPageModel.BasicInfoModel is empty...</p> <p>I think i miss understand the databinding concept :s I try this because i did not want overload my pages by small JS functions and dont like the idea t copy past my forms (code maintenance).</p> <p>Thanks by advance.</p> <p>Cantinos.</p>
 

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