且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何调用在asp.net MVC中html.actionlink javascript函数?

更新时间:2023-01-07 08:13:45

您需要使用htmlAttributes匿名对象,像这样的:

you need to use the htmlAttributes anonymous object, like this:

<%= Html.ActionLink("linky", "action", "controller", new { onclick = "someFunction();"}) %>

您也可以给它一个ID的重视它与jQuery /不管,像这样的:

you could also give it an id an attach to it with jquery/whatever, like this:

<%= Html.ActionLink("linky", "action", "controller", new { id = "myLink" }) %>


$('#myLink').click(function() { /* bla */ });