Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing Eval parameter to a JavaScript function from ASPX file

Tags:

asp.net

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" />      
like image 384
dani Avatar asked Sep 11 '09 19:09

dani


2 Answers

Try this instead.

<asp:ImageButton ID="btnOK" OnClientClick='<%# Eval("Title", "Show({0});return false;") %>' runat="server" ImageUrl="Images/icon.gif" />
like image 149
Phaedrus Avatar answered Oct 12 '22 12:10

Phaedrus


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.

like image 21
Pankaj Kumar Avatar answered Oct 12 '22 13:10

Pankaj Kumar