Sachin Kainth
Sachin Kainth

Reputation: 46750

@Html.ActionLink calling Post method

I have a @HTML.ActionLink in my Razor view and I'd like for it to call a Post action method rather than a Get one.

Is this possible?

Upvotes: 4

Views: 24385

Answers (3)

Liz Nett
Liz Nett

Reputation: 149

If you are using bootstrap you can easily make a button look like a link by applying the btn-link class, for example

<input type="submit" name="ActionType" value="Edit" class="col-md-1 btn btn-link" />

Upvotes: 6

Ren&#233; Wolferink
Ren&#233; Wolferink

Reputation: 3548

Yes and no. Normal ActionLinks will be normal links. Either you have to use a form (with method being post of coorse) and have a link sumbit it. Or you could add in a but of javascript and a nice extension.

Have a look at http://dr2ab.wordpress.com/2011/07/25/linkbuttons-in-mvc-razor/

Might be something for you.

Upvotes: 1

jwaliszko
jwaliszko

Reputation: 17064

If you want to invoke POST action, put this link inside form which uses POST action, or use ajax version. You can find some more details here.

Upvotes: 4

Related Questions