I have added a click event to the rows of a devexpress gridview on the server-side (VB.net).
Protected Sub gvSubNotes_HtmlRowPrepared(sender As Object, e As ASPxGridViewTableRowEventArgs)
e.Row.Attributes.Add("onclick", String.Format("OnEntryClick('{0}', '{1}', '{2}', '{3}');", e.GetValue("ID"), e.GetValue("SYNOPSIS"), e.GetValue("ENTRY"), e.GetValue("ENTERED_BY")))
End Sub
When executing, the bag value for e.Row.Attributes is:
OnEntryClick('1375', 'Forager', 'UPDATED on 9/12/2023 8:39:07 AM: UPDATED on 9/12/2023 8:36:32 AM: Trying to scrape up a sub for lunch. i mean for subs. yeah that's it.', 'DJANGO');
It errors out on the client side when I attempt the click. The source shown in the chrome DevTools:
<tr id="gvSubNotes_DXDataRow0" class="dxgvDataRow" onclick="OnEntryClick('1375', 'Forager', 'UPDATED on 9/12/2023 8:39:07 AM: UPDATED on 9/12/2023 8:36:32 AM: Trying to scrape up a sub for lunch.&nbsp; &nbsp;i mean for subs.&nbsp; yeah that's it.', 'DJANGO');" onmouseover="OnEntryMouseOver(this);" onmouseout="OnEntryMouseOut(this);" style="background-color:White;">
<td class="dxgv" style="color:Black;background-color:Beige;">9/11/2023</td> <!--ERROR HERE -->
<td class="dxgv dx-ellipsis" style="color:Black;">Forager</td>
<td class="dxgvPHEC dxgv" style="color:Black;background-color:Beige;">DJANGO</td>
<td class="dxgvHEC"></td>
</tr>
with the error "Uncaught SyntaxError: missing ) after argument list" at the first td
I've done this many times before. This is the first time I've run across this. Not sure where I messed up, so I need an extra set of eyes, if possible. Appreciate the help.
In your example the result of e.GetValue("ENTRY") returns a string that includes a single quote in the middle - "that's it" - which terminates the string after "that".
Depending on what you expect the values to be you could either use double quotes
or you need to clean up the string values before constructing the function call, maybe by getting rid of single quotes