NickP
NickP

Reputation: 1414

Html.ActionLink as button not hyperlink

Cannot seem to find the code that relates to this implementation in VB but I have an action link which currently displays as a hyperlink:

@Html.ActionLink("Edit", "Edit", New With {.id = currentItem.CustomerId}) 

But would like it to be displayed as a button instead as am using twitter bootstrap and the buttons defined in the CSS look amazing. I know how to define a button link normally but how would I change the action link to one?

Upvotes: 3

Views: 3008

Answers (2)

Eranga
Eranga

Reputation: 32437

Set the CSS class property to btn.

@Html.ActionLink("Edit", "Edit", New With {.id = currentItem.CustomerId}, New With {.class = "btn"}) 

Upvotes: 5

Florim Maxhuni
Florim Maxhuni

Reputation: 1421

you should do a extension method

public static class MVCExtensions
    {
public static string SubmitButton(this HtmlHelper helper, string buttonText)
        {
            return String.Format("<input type=\"submit\" value=\"{0}\" />", buttonText);
        }
}

then you call in code

@Html.SubmitButton("Save")

Upvotes: 1

Related Questions