I need to mix and match JavaScript and C# using Razor syntax in the same statement. I could be using @: wrong for writing JavaScript inside of Razor code because the last expression in the Razor code block breaks all the JavaScript after the block.
var myVar = document.getElementById("myId");
var linkText = "someText";
var JSVar = X; //X represents some number
@{
int ID = JSVar;
@:myVar.innerHTML = @Html.ActionLink(@:linkText, "Details", "Cards", new { Id = ID});
}
I've also tried to accomplish this as a single expression without the code block, like this:
myVar.innerHTML = @Html.ActionLink(@:linkText, "Details", "Cards", new { Id = @:IdVar });
This breaks the following JavaScript as well.