Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 671
NickP Avatar asked Sep 15 '26 06:09

NickP


2 Answers

Set the CSS class property to btn.

@Html.ActionLink("Edit", "Edit", New With {.id = currentItem.CustomerId}, New With {.class = "btn"}) 
like image 117
Eranga Avatar answered Sep 17 '26 05:09

Eranga


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")
like image 25
Florim Maxhuni Avatar answered Sep 17 '26 07:09

Florim Maxhuni