Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use normal HTML Button to call Controller in ASP.NET MVC2?

I want to use normal HTML Button to call Controller in ASP.NET MVC2, instead of ActionLink, is that possible?

like image 279
user469652 Avatar asked Dec 02 '25 20:12

user469652


1 Answers

Sure, just use Url.Action() to render the URL to the action.

<a href="<%= Url.Action("Action") %>">BLA BLA</a>

or

<button onclick="javascript: window.location = '<%= Ajax.JavascriptEncode(Url.Action("Action")) %> '">Click me</button>
like image 59
Gideon Avatar answered Dec 04 '25 09:12

Gideon