Razor 按右边的按钮登录

Razor 按右边的按钮登录,razor,twitter-bootstrap,Razor,Twitter Bootstrap,我正在尝试将MVC Asp应用程序默认附带的登录部分更改为一个按钮,并移动到导航栏的右侧(我正在使用twitter引导)。我基本上希望我的按钮看起来像一个示例(bootstap的v2.1版似乎不再有了),它在站点上显示为一个person silohette,右边是一个按钮。我不确定是否有人知道我在说什么 我的HTMLPartial如下所示: @If Request.IsAuthenticated Then @<text>Welcome <strong&g

我正在尝试将MVC Asp应用程序默认附带的登录部分更改为一个按钮,并移动到导航栏的右侧(我正在使用twitter引导)。我基本上希望我的按钮看起来像一个示例(bootstap的v2.1版似乎不再有了),它在站点上显示为一个person silohette,右边是一个按钮。我不确定是否有人知道我在说什么

我的HTMLPartial如下所示:

    @If Request.IsAuthenticated Then
        @<text>Welcome <strong>@User.Identity.Name</strong>!
        @Html.ActionLink("Log Off", "LogOff", "Account")</text>
    Else
        @:@Html.ActionLink("Log On", "LogOn", "Account")
    End If


但是这会产生一个非常大的按钮,具有奇怪的行为,并且登录时的名称不在按钮中(而是显示在按钮上方)。

您不应该使用带li标记的向右拖动。 这应该用div来完成。你必须把你的代码放到下面的html中,然后你就没事了

<div class="btn-group pull-right">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">$Account</a><span class="caret"></span>
<ul class="dropdown-menu"><li>whatever you like</li><li>whatever you like</li></ul>
</div>

  • 你喜欢什么都行
  • 你喜欢什么都行
希望这会有所帮助:)

@Html.ActionLink("Log On", "LogOn", "Account")
@Html.ActionLink("Log On", "LogOn", "Account", New With {.class = "btn"})
<div class="btn-group pull-right">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">$Account</a><span class="caret"></span>
<ul class="dropdown-menu"><li>whatever you like</li><li>whatever you like</li></ul>
</div>