Created
August 6, 2013 01:29
-
-
Save RyannosaurusRex/6161247 to your computer and use it in GitHub Desktop.
Html.BeginForm will cause unwanted breaking of styling on most pages, particularly if you're placing it in a nav or similar area. This gist demonstrates how to move the Logout link, which in the ASP.NET MVC starter project is implemented using a form, to somewhere else on the page. We then fire it using some javascript in a link somewhere else o…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
This javascript code will find the logout form on your page and do the submit. | |
We do this separation so we can have total control over styling. | |
--> | |
<a href="javascript:document.getElementById('logoutForm').submit()">Logout!</a> | |
<!-- | |
Put this form anywhere you want outside your content area so styling isn't jacked up. | |
--> | |
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-form pull-right" })) | |
{@Html.AntiForgeryToken()} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment