Uncaught SyntaxError: missing ) after argument list

QuestionsCategory: Asp.netUncaught SyntaxError: missing ) after argument list
Harry Dew asked 1 year ago

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>

 

1 Answers
Best Answer
Shehryar Khan Staff answered 1 year ago

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>