Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
48
rated 0 times [  50] [ 2]  / answers: 1 / hits: 161746  / 14 Years ago, tue, may 18, 2010, 12:00:00

How can one call a javascript function in html.actionlink in asp.net mvc?


I want to call one method, which is in JavaScript, but how I call it within html.actionlink in the same page?


More From » asp.net

 Answers
7

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

[#96755] Saturday, May 15, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parker

Total Points: 259
Total Questions: 109
Total Answers: 97

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;