Tippu
Tippu

Reputation: 1261

The server tag is not well formed

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")%>');"/> 

Upvotes: 3

Views: 13391

Answers (2)

James Johnson
James Johnson

Reputation: 46047

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")%>\");'

Upvotes: 10

atbebtg
atbebtg

Reputation: 4083

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

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

Upvotes: 0

Related Questions