小编Pow*_*ow5的帖子

如何在MVC 5中实现Bootstrap边栏

我想在中实现导航侧边栏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>&copy; @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)

html css asp.net asp.net-mvc twitter-bootstrap

5
推荐指数
0
解决办法
7119
查看次数

ASP.NET MVC Bootstrap动态模态内容

我正在使用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.我怎样才能做到这一点?

asp.net asp.net-mvc jquery twitter-bootstrap

5
推荐指数
1
解决办法
9733
查看次数

ViewModel 或 Model 中的 ASP.NET MVC 验证?

我有一个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)

c# asp.net-mvc

4
推荐指数
2
解决办法
1392
查看次数

标签 统计

asp.net-mvc ×3

asp.net ×2

twitter-bootstrap ×2

c# ×1

css ×1

html ×1

jquery ×1