3

I have the following image button on the GridView and I want to call the OnClientClick to call javascript method with passing a parameter. I am getting Server Tag is not well formed error. I tried changing double quotes to single quote etc, still the same issue.

OnClientClick="return ConfirmOnDelete('<%#Eval("Name")%>');"

<asp:ImageButton ID="imgDelete" CommandName="Delete" ImageUrl="~/images/fbclose.png" AlternateText="Delete"  runat="server" OnClientClick="return ConfirmOnDelete('<%#Eval("Name")%>');"/> 
Davide Piras
  • 43,984
  • 10
  • 98
  • 147
Tippu
  • 1,191
  • 4
  • 16
  • 36

2 Answers2

10

You need to use single quotes around the OnClientClick property:

OnClientClick='return ConfirmOnDelete(<%#Eval("Name")%>);'

You also had an orphaned single quote after the Eval function. If you need to wrap the value that you're passing into the function with quotes, you can do this:

OnClientClick='return confirmOnDelete(\"<%#Eval("Name")%>\");'
James Johnson
  • 45,496
  • 8
  • 73
  • 110
0

OnClientClick="return ConfirmOnDelete(<%#Eval("Name")%>') you only have one single quote at the end change it to

OnClientClick='return ConfirmOnDelete(<%#Eval("Name")%>)'
atbebtg
  • 4,023
  • 9
  • 37
  • 49