Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Figure out 2 method to achieve mine goal</p> <p>1) Passing the main model to each partial view, sample of partial view :-</p> <pre><code>@model TestingMVC4.Models.Main //@model TestingMVC4.Models.PartialA &lt;fieldset&gt; &lt;legend&gt;PartialA&lt;/legend&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.PA.UserName) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.PA.UserName) @Html.ValidationMessageFor(model =&gt; model.PA.UserName) &lt;/div&gt; &lt;div class="editor-label"&gt; @Html.LabelFor(model =&gt; model.PA.UserID) &lt;/div&gt; &lt;div class="editor-field"&gt; @Html.EditorFor(model =&gt; model.PA.UserID) @Html.ValidationMessageFor(model =&gt; model.PA.UserID) &lt;/div&gt; &lt;/fieldset&gt; </code></pre> <p>disadvantages of this method is the partial view is tight to other view.</p> <p>2) convert all partial view to become templates helpers :- reference from <a href="http://lostechies.com/jimmybogard/2011/09/07/building-forms-for-deep-view-model-graphs-in-asp-net-mvc/" rel="nofollow">http://lostechies.com/jimmybogard/2011/09/07/building-forms-for-deep-view-model-graphs-in-asp-net-mvc/</a> </p> <p>this second method is reuse able because it used it own model binding rather than model from parent, for example :-</p> <pre><code>@model TestingMVC4.Models.ProductEditModel @{ ViewBag.Title = "Index"; } &lt;p&gt; @Html.LabelFor(m =&gt; m.Name) @Html.TextBoxFor(m =&gt; m.Name) &lt;/p&gt; @Html.EditorFor(m =&gt; m.Price) @model TestingMVC4.Models.PriceEditModel &lt;p&gt; @Html.LabelFor(m =&gt; m.Currency) @Html.TextBoxFor(m =&gt; m.Currency) &lt;/p&gt; &lt;p&gt; @Html.LabelFor(m =&gt; m.Value) @Html.TextBoxFor(m =&gt; m.Value) &lt;/p&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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