Uncaught syntax error: ) missing after argument list in asp.net mvc application javascript -
i have researched on why "uncaught syntax error: ) missing after argument list" error , went through code throughly, after reading few answers on stack overflow. i've been on more day, yet error still persist. please help.
my code
function openinnewtab(filename) { var url = @url.action("displaydocuments", new { filename = filename }); var redirectwindow = window.open(url, '_blank'); redirectwindow.location.reload(true); return false; }
and calling here in view, im tring tto implement onclick functionality on image when image clicked, opens new window , displays image.
<a onclick="openinnewtab(@filename);"><img title="@filename" src="~/content/images/image.png"></a>
basically missing single quotes
, mixing js
variables in razor
code, code should -
<a onclick="openinnewtab('@filename');"><img title="@filename" src="~/content/images/image.png"></a>
and
function openinnewtab(filename) { var url = '@url.action("displaydocuments", new { filename = "tempfilename" })'; // replace templfilename actual value being passed function url = url.replace("tempfilename", filename); var redirectwindow = window.open(url, '_blank'); redirectwindow.location.reload(true); return false; }
Comments
Post a Comment