0

I have a javascript call in OnClientClick that looks like the following:

OnClientClick='<%# "return DisplayAlert(" + Eval("BedNum") + "," + Eval("ClientId") + ");" %>'

But when ClientId is null, the function call is constructed incorrectly with error Uncaught SyntaxError: Unexpected token ) since the function call produces return DisplayAlert(value, );

Is there a way to avoid this error when the 2nd parameter is null?

Thanks

fdkgfosfskjdlsjdlkfsf
  • 2,995
  • 1
  • 36
  • 86

1 Answers1

0

If I understand correctly, all you would need to do is check its value, and for null have a default value of your choosing, or the original clientId in the case that it isn't null.

Something like this:

ClientId == null ? "whateverDefaultValueYouWant" : clientId
smaili
  • 1,225
  • 9
  • 18