Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you should use Editor Templates:</p> <pre><code>@model TestWebsite.Models.FormModel @using(Html.BeginForm()) { @Html.EditorFor(x =&gt; x.Location) &lt;input type="submit" value="save"/&gt; } </code></pre> <p>and add the partial inside <code>~/Views/[ControllerName]/EditorTemplates/Location.cshtml</code> or <code>~/Views/Shared/EditorTemplates/Location.cshtml</code></p> <p>code of template:</p> <pre><code>@model TestWebsite.Models.Location &lt;tr&gt; &lt;td class="editor-label"&gt; @Html.LabelFor(m =&gt; m.CountryId) &lt;/td&gt; &lt;td class="editor-field"&gt; @Html.DropDownListFor(m =&gt; m.CountryId, Model.Countries, "---select--", null) &lt;/td&gt; &lt;td&gt; @Html.ValidationMessageFor(m =&gt; m.CountryId) &lt;/td&gt; &lt;/tr&gt; &lt;!-- Region --&gt; &lt;tr&gt; &lt;td class="editor-label"&gt; @Html.LabelFor(m =&gt; m.RegionId) &lt;/td&gt; &lt;td class="editor-field"&gt; @Html.DropDownListFor(m =&gt; m.RegionId, Enumerable.Empty&lt;SelectListItem&gt;(), "---select--", null) &lt;/td&gt; &lt;td&gt; @Html.ValidationMessageFor(m =&gt; m.RegionId) &lt;/td&gt; &lt;/tr&gt; &lt;!-- City --&gt; &lt;tr&gt; &lt;td class="editor-label"&gt; @Html.LabelFor(m =&gt; m.CityId) &lt;/td&gt; &lt;td class="editor-field"&gt; @Html.DropDownListFor(m =&gt; m.CityId, Enumerable.Empty&lt;SelectListItem&gt;(), "---select--", null) &lt;/td&gt; &lt;td&gt; @Html.ValidationMessageFor(m =&gt; m.CityId) &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>But if you prefer to have partial in some location (not follow conventions) you could specify the location:</p> <pre><code>@Html.EditorFor(x =&gt; x.Location, "~/Views/SpecifyLocation/_Location.cshtml") </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.
    3. VO
      singulars
      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