I have the following Javascript code:
var idJS;
$('.disp').click(function () {
idJS = $(this).attr("id");
})
And then I want to do this:
@Ajax.ActionLink("myMethod", "myMethod", "HomeController", new { id = idJS },
new AjaxOptions() { HttpMethod = "Get", UpdateTargetId = "myDiv" })
Is it possible to do this?
This is not possible to do because Razor view code is rendered when the page it loaded, so all that code is resolved (transformed to HTML) before the javascript can even execute.
You can however use Javascript to change properties of a link, like the following for example (using JQuery though I am afraid, look up a javascript equivalent if need be)
ok I will look it up then, javascript only: