6

I try to pass Eval value like this but get syntax errors:

<asp:ImageButton ID="btnOK" OnClientClick='Show("<%#Eval("Title")%>");return false;'  runat="server" ImageUrl="Images/icon.gif" />      
dani
  • 1,077
  • 7
  • 19
  • 27

2 Answers2

8

Try this instead.

<asp:ImageButton ID="btnOK" OnClientClick='<%# Eval("Title", "Show({0});return false;") %>' runat="server" ImageUrl="Images/icon.gif" />
Phaedrus
  • 8,351
  • 26
  • 28
1
OnClientClick='<%#String.Format("Show('{0}');return false;",Eval("title"))%>'

or you if do it in the design view just add a databinding for the imagebutton's onClientClick property as

String.Format("Show('{0}');return false;",Eval("title"))

hope it helps you.

Serkan Arslan
  • 13,158
  • 4
  • 29
  • 44
Pankaj Kumar
  • 1,748
  • 6
  • 28
  • 41