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


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



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




Selling upper management on converting to ASP.NET from Classic ASP

1:



Membership provider stopped working on using Membership Provider in ASP.Net MVC
you need to use the htmlAttributes anonymous object, like this:.
Design decisions
<%= Html.ActionLink("linky", "action", "controller", new { onclick = "someFunction();"}) %> 
you could also give it an id an attach to it with jquery/whatever, like this:.
ASP.NET Exception Handling in background threads
<%= Html.ActionLink("linky", "action", "controller", new { id = "myLink" }) %>   $('#myLink').click(function() { /* bla */ }); 


MVC2 or WCF for an XML/JSON REST API?


How do you update the aspnetdb membership IsApproved value?

2:



Restrict file types allowed for upload asp.net
For calling javascript in your action link you simply need to write actionlink like this:.
MVC & EF - using
@Html.ActionLink("Delete", "Your-Action", new { id = item.id },                  new { onclick="return confirm('Are you sure?');"}) 
Don't get confused between route values and the html attributes..


3:


@Html.ActionLink("Edit","ActionName",new{id=item.id},new{onclick="functionname();"}) 


4:


<a onclick="MyFunc()">blabla..</a> 
There is nothing more in @Html.ActionLink that you could utilize in this case.

And razor is evel by itself, drop it from where you can..



77 out of 100 based on 62 user ratings 487 reviews