我想在中实现导航侧边栏MVC 5,但在Bootstrap 3该项目随附的中找不到任何内置类。我尝试使用以下代码:
_Layout.cshtml
<body>
//the sidebar code is here...
<div id="Wrapper">
<ul>
<li>hello</li>
<li>Project</li>
<li>Account settings</li>
</ul>
</div>
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
<li>@Html.ActionLink("About", "About", "Home")</li>
<li>@Html.ActionLink("Contact", "Contact", "Home")</li>
</ul>
@Html.Partial("_LoginPartial")
</div>
</div>
</div>
<div class="container body-content" id="page-content-wrapper">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year/p>
</footer>
</div>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
<link href="~/Content/Custom.css" …Run Code Online (Sandbox Code Playgroud) 我正在使用MVC 5,我<button>在每个记录中都有viewModel以下内容:
<table class="table table-hover">
<tr>
<th>
@Html.DisplayNameFor(model => model.Questions.Single().QuestionType)
</th>
<th>
@Html.DisplayNameFor(model =>model.Questions.Single().Scheme)
</th>
</tr>
@foreach (var item in Model.Questions)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.QuestionType)
</td>
<td>
<button type="button" class="btn btn-success btn-sm" data-toggle="modal" data-target="#myModal" >
View
</button>
</td>
</tr>
}
Run Code Online (Sandbox Code Playgroud)
Foreach (Var item in Model.Questions),会有一个button开放的modal.但是,我想modal根据item.idfrom 加载不同的内容Model.Questions.我怎样才能做到这一点?
我有一个model包含基本信息的。但是,我View需要更多的信息只是为了显示,所以我认为ViewModel这里需要a来显示额外的信息。但是,我应该Validation attributes在模型中添加 ,以便当我执行时Code-First migration,它会自动database为我创建datatype每列正确的,还是我应该将 添加Validation attributes到 ViewModel 因为表单应该validate填写信息?
public class Module
{
[Key]
public int id { get; set; }
[Required]
[StringLength(100)]
[Column(TypeName = "varchar")]
[Display(Name="Module Name")]
public string ModuleName { get; set; }
}
public class ModuleViewModel
{
[Key]
public int id { get; set; }
[Required]
[StringLength(30)]
[Column(TypeName="varchar")]
[Display(Name="Module ID")]
public string ModuleID { get; set; }
[Required]
[StringLength(100)]
[Column(TypeName …Run Code Online (Sandbox Code Playgroud)