I am programming an ASP.NET web application. I have a button with an onclick
event that triggers a Javascript function with a few parameters.
When I click on the button the following error gets thrown in the browser console:
Uncaught SyntaxError: missing ) after argument list (at BusinessUnit?buLeaderId=18:212:176)
When I click on the link after "at" it marks this part of the code:
<a id="@employee.Id"
onclick="NewAdGroupDeletionRecord(@adGroup.Name, @employee.FirstName @employee.LastName, false)">
<i ></i>
</a>
I can't seem to find anything wrong with it, especially considering that there is a closing bracket after the parameters.
Here is my code:
HTML:
<table id="DataTable" >
<thead>
<tr style="text-align: left;">
<th>AD Gruppe</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var adGroup in employee.AdGroups)
{
<tr>
<th style="text-align: left;">@adGroup.Name</th>
<th>
<div role="group" aria-label="Basic example">
<a id="@employee.Id" onclick="NewAdGroupDeletionRecord(@adGroup.Name, @employee.FirstName @employee.LastName, false)">
<i ></i>
</a>
</div>
</th>
</tr>
}
</tbody>
</table>
JS:
<script>
function NewAdGroupDeletionRecord(adGroupName, employeeName, canDelete){
console.log(adGroupName);
console.log(employeeName);
console.log(canDelete);
}
</script>
Thanks in advance for anyone who takes the time to look at my question.
CodePudding user response:
The problem was here: @employee.FirstName @employee.LastName
Adding the lastname as a sepperate parameter fixed the problem.
Edit: also '' has to be added to around each parameter that you want to be treatet as a string.