无法使按钮看起来正确

时间:2015-01-09 11:41:52

标签: c# html asp.net

现在我读了“ ASP.NET MVC5,Freeman ”一书,我创建了一个网站。 这是它的样子:

enter image description here

按钮主页必须看起来像另一个按钮,我无法理解,有什么不对。 我是ASP.NET的新手,所以我不知道,为什么要查找错误。

这是我项目的结构:

  • SportsStore.Domain - for logic
  • SportsStore.UnitTests - for tests
  • SportsStore.WebUI - 用于视图和控制器

enter image description here

我认为,问题出现在SportsStore.WebUI中。

Menu.schtml:

@model IEnumerable<string>

@Html.ActionLink("Home", "List", "Product", null,
                     new { @class = "btn btn-block btn-defautl btn-lg" })
@foreach (var link in Model)
{
    @Html.RouteLink(link, new
    {
        controller = "Product",
        action = "List",
        category = link,
        page = 1
    }, new
   {
        @class = "btn btn-block btn-default btn-lg"
            + (link == ViewBag.SelectedCategory ? " btn-primary" : "")
    })
}

List.cshtml

@model SportsStore.WebUI.Models.ProductsListViewModel

@{
    ViewBag.Title = "Products";
}

@foreach (var p in Model.Products )
{
    @Html.Partial("ProductSummary", p)
}

<div class="btn-group pull-right">
    @Html.PageLinks(Model.PagingInfo, x => Url.Action("List",
        new { page = x, category = Model.CurrentCategory }))
</div>

Edit1 - 生成的HTML代码

<html><div id="coFrameDiv" style="height:0px;display:none;"><iframe id="coToolbarFrame" src="chrome-extension://cjabmdjcfcfdmffimndhafhblfmpjdpe/toolbar/placeholder.html" style="height: 0px; width: 100%; display: none;"></iframe></div><head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="/Content/bootstrap.css" rel="stylesheet">
    <link href="/Content/bootstrap-theme.css" rel="stylesheet">
    <title>Products</title>
<link rel="stylesheet" id="coToolbarStyle" href="chrome-extension://cjabmdjcfcfdmffimndhafhblfmpjdpe/toolbar/styles/placeholder.css" type="text/css"><script type="text/javascript" id="cosymantecbfw_removeToolbar">(function () {             var toolbarElement = {},                    parent = {},                    interval = 0,                   retryCount = 0,                 isRemoved = false;              if (window.location.protocol === 'file:') {                 interval = window.setInterval(function () {                     toolbarElement = document.getElementById('coFrameDiv');                     if (toolbarElement) {                           parent = toolbarElement.parentNode;                         if (parent) {                               parent.removeChild(toolbarElement);                             isRemoved = true;                               if (document.body && document.body.style) {                                 document.body.style.setProperty('margin-top', '0px', 'important');                              }                           }                       }                       retryCount += 1;                        if (retryCount > 10 || isRemoved) {                         window.clearInterval(interval);                     }                   }, 10);             }           })();</script></head>
<body>
    <div class="navbar navbar-inverse" role="navigation">
        <a class="navbar-brand" href="#">SPORTS STORE</a> 
    </div>
    <div class="row panel">
        <div id="categories" class="col-xs-3">
            <a class="btn btn-block btn-defautl btn-lg" href="/">Home</a>
<a class="btn btn-block btn-default btn-lg" href="/Chess">Chess</a><a class="btn btn-block btn-default btn-lg" href="/Soccer">Soccer</a><a class="btn btn-block btn-default btn-lg" href="/Watersports">Watersports</a>;
        </div>
        <div class="col-xs-8">


<div class="well">
    <h3>
        <strong>Kayak</strong>
        <span class="pull-right label label-primary">275,00 ₽</span>
    </h3>
    <span class="lead">A boat for one person</span>
</div><div class="well">
    <h3>
        <strong>Lifejacket</strong>
        <span class="pull-right label label-primary">48,95 ₽</span>
    </h3>
    <span class="lead">Protective and fascionable</span>
</div><div class="well">
    <h3>
        <strong>Soccre ball</strong>
        <span class="pull-right label label-primary">19,50 ₽</span>
    </h3>
    <span class="lead">FIFA-approver size and weight</span>
</div><div class="well">
    <h3>
        <strong>Corner Flags</strong>
        <span class="pull-right label label-primary">34,95 ₽</span>
    </h3>
    <span class="lead">Give you playing field a professional touch</span>
</div>
<div class="btn-group pull-right">
    <a class="btn btn-default btn-primary selected" href="/">1</a><a class="btn btn-default" href="/Page2">2</a><a class="btn btn-default" href="/Page3">3</a>
</div>
        </div>
    </div>

<!-- Visual Studio Browser Link -->
<script type="application/json" id="__browserLink_initializationData">
    {"appName":"Chrome","requestId":"71da9908a09f40e490a8f3c96abdeaaa"}
</script>
<script type="text/javascript" src="http://localhost:60023/6e11616ea0ef4c01be4ca7cc7741a6e8/browserLink" async="async"></script>
<!-- End Browser Link -->


</body></html>

也许它会有所帮助: https://github.com/dmitrykozyr/SportsStoreMVC

使用类别 - 文件的一部分_Layout.cshtml

<body>
    <div class="navbar navbar-inverse" role="navigation">
        <a class="navbar-brand" href="#">SPORTS STORE</a> 
    </div>
    <div class="row panel">
        <div id="categories" class="col-xs-3">
            @Html.Action("Menu", "Nav");
        </div>
        <div class="col-xs-8">
            @RenderBody()
        </div>
    </div>
</body>

1 个答案:

答案 0 :(得分:1)

创建主页链接时,您有默认拼写错误

@Html.ActionLink("Home", "List", "Product", null,
                 new { @class = "btn btn-block btn-defautl btn-lg" })

应该是

@Html.ActionLink("Home", "List", "Product", null,
                 new { @class = "btn btn-block btn-default btn-lg" })