I plan to use some Model properties to manage JavaScript code in HTML/Razor.
"columnDefs": [
{
"render": function (data, type, row) {
@if (Model.ConfigViewModel.AllowDeleteAnyUsers)
{
return '<center><img class="cursor-hand" onclick="javascript:ConfirmRemoveUser(this)" data-userId="' + row.Id + '" data-userName="' + row.UserName + '" src="images/delete.png" width="16" height="16" border="0"></center>'
}
else
{
return '<center><img class="cursor-hand" onclick="javascript:ConfirmRemoveUser(this)" data-userId="' + row.Id + '" data-userName="' + row.UserName + '" src="images/delete-disabled.png" width="16" height="16" border="0"></center>'
}
},
"targets": 3
}
But elements of JS code like row.Id are giving errors like.
Compiler Error Message: CS1012: Too many characters in character literal
Any clue how to combine Razor and JS?