Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It would seem that you're trying to render a partial view from a controller action as part of the larger view. In this case, the partial view should be rendered within the <code>ProfileAccount</code> view. </p> <p>You can structure the controller and views like this (rough outline):</p> <p><strong>ProfileAccount View Model</strong>:</p> <pre><code>public class ProfileAccountView { public StudentNameModel StudentName { get; set; } } </code></pre> <p><strong>Profile Controller</strong>:</p> <pre><code>[HttpGet] public ActionResult ProfileAccount(int id) { // Get whatever info you need and store in a ViewModel var model = new ProfileAccountView(); // Get the student info and store within ProfileAccountView // Do your database reads model.StudentName = new StudentNameModel { StudentName = result }; return View(model); } [HttpPost] public ActionResult ProfileAccount(ProfileAccountView profile) { // Do whatever processing here } </code></pre> <p><strong>ProfileAccount View</strong></p> <pre><code>@model School.Models.ProfileAccountView @using (Html.BeginForm("ProfileAccount", "Profile")) { @Html.RenderPartial('_StudentNamePartial', Model.StudentName); &lt;button type="button" value="save" /&gt; } </code></pre> <p><strong>_StudentNamePartial Partial View</strong></p> <pre><code>@model School.Models.StudentNameModel &lt;fieldset&gt; &lt;ol&gt; &lt;li&gt; @Html.LabelFor(m =&gt; m.StudentName) @Html.TextBoxFor(m=&gt;m.StudentName) &lt;/li&gt; &lt;/ol&gt; &lt;/fieldset&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.
 

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