Click here to Skip to main content
14,733,955 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am want to bind Eval in javascript function

<asp:ImageButton runat="server" ImageUrl="/ESDNET/Images/Icons/add.png" OnClientClick="return ShowNewNoteForm('<%# Eval("SuggestionID").ToString() %>');"/>
Updated 11-Nov-20 20:35pm
Kornfeld Eliyahu Peter 22-Jul-14 5:47am
And? Someone do not let you?

Try this:
 onclick='<%# "ShowNewNoteForm(" +Eval("SuggestionID") + " );" %>'
Member 14937964 12-Nov-20 1:36am
not working above method

use this
OnClientClick='<%# String.Format("javascript:return confrimPosting(\"{0}\")", Eval("IsBlockPosting").ToString()) %>'
CHill60 12-Nov-20 5:16am
It clearly did work back in 2014 as the OP accepted the answer. It won't have worked exactly as typed for you because you are trying to Eval something entirely different
Richard Deeming 12-Nov-20 5:56am
It was accepted as the solution, but it wouldn't have worked with the OP's code. onclick specifies the handler for the server-side click event.
CHill60 12-Nov-20 6:26am
I definitely need to get my eyes tested - I read that as OnClientClick - seeing what I'm expecting to see I guess
This is solution which is working

OnClientClick='<%# String.Format("javascript:return confrimPosting(\"{0}\")", Eval("IsBlockPosting").ToString()) %>'
CHill60 12-Nov-20 5:22am
Reasons for my downvote:
- An unformatted uncommented code dump is not a good solution
- It contains a spelling mistake
- The ToString() call is unnecessary
Richard Deeming 12-Nov-20 5:58am
No need for the string.Format call - Eval can do that for you.
OnClientClick='<%# Eval("IsBlockPosting", "return confirmPosting(\"{0}\")") %>'

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900