I’m trying to implement the solution provided in this question here:
How to pass Model Value through ActionLink
So in my view I have an action link
@Html.ActionLink("Look up registration", "RegLookup", "Vehicle", new {@id="check"},null)
And in a Javascript file I have :
$(function ()
{
$("#check").click(function (e) {
e.preventDefault();
}
I’ve cut the function down to just preventing the default action of the action link.
In the view I’ve also referenced the java script files
<script src="~/Scripts/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.js" type="text/javascript"></script>
<script src="~/Scripts/GetRegistrationPlate.js" type="text/javascript"></script>
However when I click on the action link the default method continues to fire.
What might I have missed?
For one there are many syntax errors. Try this
Edit: Also, change the ActionLink to
The first id is for the route, the second id is for the html element.