Search code examples
c#htmlcssasp.net-mvc-5asp.net-mvc-5.1

Change button style in MVC5 view


I use the following view code which I created in MVC5 and I want to change the button style to be like the forum buttons (e.g. ask question button in this stack forum,add button frame color etc),how should I do that? currently its just text that when you hoover it with the mouse you see line under it...

<p>
    @Html.ActionLink("Create New Item", "Create")
</p>

Solution

  • You just need css to style a button.

    enter image description here

    <p>
        @Html.ActionLink("Create New Item", "Create", 
            null, htmlAttributes: new { @class = "mybtn"})
    </p>
    <style type="text/css">
        a.mybtn {
            background: #777;
            color: #fff;
            display: inline-block;
            padding: 6px 12px 6px 12px;
            text-decoration: none;
        }
    </style>