Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'd recommend using <code>Html.RenderAction</code> and PartialViewResults to accomplish this; it will allow you to display the same data, but each partial view would still have a single view model and removes the need for a <code>BigViewModel</code></p> <p>So your view contain something like the following:</p> <pre><code>@Html.RenderAction("Login") @Html.RenderAction("Register") </code></pre> <p>Where <code>Login</code> &amp; <code>Register</code> are both actions in your controller defined like the following:</p> <pre><code>public PartialViewResult Login( ) { return PartialView( "Login", new LoginViewModel() ); } public PartialViewResult Register( ) { return PartialView( "Register", new RegisterViewModel() ); } </code></pre> <p>The <code>Login</code> &amp; <code>Register</code> would then be user controls residing in either the current View folder, or in the Shared folder and would like something like this:</p> <p>/Views/Shared/Login.cshtml: (or /Views/MyView/Login.cshtml)</p> <pre><code>@model LoginViewModel @using (Html.BeginForm("Login", "Auth", FormMethod.Post)) { @Html.TextBoxFor(model =&gt; model.Email) @Html.PasswordFor(model =&gt; model.Password) } </code></pre> <p>/Views/Shared/Register.cshtml: (or /Views/MyView/Register.cshtml)</p> <pre><code>@model ViewModel.RegisterViewModel @using (Html.BeginForm("Login", "Auth", FormMethod.Post)) { @Html.TextBoxFor(model =&gt; model.Name) @Html.TextBoxFor(model =&gt; model.Email) @Html.PasswordFor(model =&gt; model.Password) } </code></pre> <p>And there you have a single controller action, view and view file for each action with each totally distinct and not reliant upon one another for anything.</p>
    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. 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.
 

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