tags:

views:

259

answers:

1

how to call javascript function in html.actionlink in asp.net mvc?

i wan to call one method which is in java script but how to call it within html.actionlink in same page thanks in advance

A: 

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

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

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 */ });
Andrew Bullock