Note that there are some explanatory texts on larger screens.

plurals
  1. POModel in Layout breaks other pages
    primarykey
    data
    text
    <p>I have a design flaw based on my lack of MVC4 experience.</p> <p>The issue is that I have a model in my Layout...</p> <pre><code>@model BasicFinanceUI.Models.LoginModel &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta name="viewport" content="width=device-width, initial-scale=1.0" /&gt; &lt;link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /&gt; &lt;link href="@Url.Content("~/Content/bootstrap.min.css")" rel="stylesheet"/&gt; &lt;title&gt;@ViewBag.Title&lt;/title&gt; &lt;/head&gt; </code></pre> <p>The reason it's on my Layout, is that the Login button is on the layout screen, and it launches a modal popup, which has fiends that use the model.</p> <p>So, at the bottom of the layout, I have:</p> <pre><code>&lt;div class="modal fade" id="login" role="dialog"&gt; &lt;div class="modal-dialog"&gt; &lt;div class="modal-content"&gt; &lt;div class="modal-header"&gt; &lt;h3&gt;Login&lt;/h3&gt; &lt;div class="modal-body"&gt; @using (Html.BeginForm("LoginUser", "User")) { &lt;p&gt; @Html.LabelFor(x =&gt; x.Username) @Html.TextBoxFor(x =&gt; x.Username) &lt;/p&gt; &lt;p&gt; @Html.LabelFor(x =&gt; x.Password) @Html.PasswordFor(x =&gt; x.Password) &lt;/p&gt; &lt;p&gt; @Html.LabelFor(x =&gt; x.RememberMe) @Html.CheckBoxFor(x =&gt; x.RememberMe) &lt;/p&gt; &lt;div class="modal-footer"&gt; &lt;input type="submit" value="Login" name="btn_login" class="btn btn-default" /&gt; &lt;a class="btn btn-primary" data-dismiss="modal"&gt;Cancel&lt;/a&gt; &lt;/div&gt; } &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I also have a Login and Logout button on my /Home/Index, so the user see's two login buttons when on the default page. One on the main page, and one in the header/menu, which is shared.</p> <p>I think having the model, and probably all the Login screen code, on the Layout page, might be the problem here. How should I be implementing this?</p> <p>I need the Login button on the Index.cshtml page (Default), and the button in the Layout's menu at the top. And both use the model popup code shown above.</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.
 

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