Hi,
In my ASP.NET MVC application View, I’m getting this error in my browser console
Uncaught SyntaxError: missing ) after argument list
here’s my code for passing parameters to JavaScript function
<a href="javascript:EditUser( @item.id , @item.name );">Edit</a>
and this is for receiving Parameters
<script> function EditUser(id, name) { alert(name); } </script>
Disclosure of Material Connection: Some of the links in the post above are “affiliate links.” This means if you click on the link and purchase the item, we will receive an affiliate commission. Regardless, we only recommend products or services we use personally and believe will add value to our readers.
just add single quotes with parameters and change this line
<a href="javascript:EditUser( @item.id , @item.name );">Edit</a>
to this
<a href="javascript:EditUser( '@item.id' , '@item.name' );">Edit</a>
Disclosure of Material Connection: Some of the links in the post above are “affiliate links.” This means if you click on the link and purchase the item, we will receive an affiliate commission. Regardless, we only recommend products or services we use personally and believe will add value to our readers.