Click here to Skip to main content
16,016,693 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I was trying to return values using Eval but got an error saying that the value is undefined. I'm attaching code snippet for same. The value returned correctly if I was using an integer value but said undefined for some string values.

XML
<asp:LinkButton Text="" ID="deleteImageButton" runat="server" CommandName="Delete"
                                       CssClass="deleteButton" OnClientClick='<%# "return ConfirmationMessage(" + Eval("event_name").ToString() + ");" %>' />


C#
function ConfirmationMessage(eventType) {
            if (eventType != null && eventType != 'undefined')
                return confirm(eventType);
        }


Please let me know where i am wrong and help me out please.

Thank in advance,
NutanR
Posted

There is an issue on how you are forming your OnClientClick with Eval.

Try:
JavaScript
OnClientClick='<%# Eval("event_name", "return ConfirmationMessage(\"{0}\");") %>'
 
Share this answer
 
Comments
Nutan R 30-Aug-12 2:07am    
Thanks a lot..Thanks
Kuthuparakkal 30-Aug-12 2:09am    
my 5+
try :

ASP.NET
<asp:linkbutton text="" id="deleteImageButton" runat="server" commandname="Delete"                                        CssClass="deleteButton" OnClientClick="return ConfirmationMessage('<%# Eval("event_name")%>'  )"</asp:linkbutton>
 
Share this answer
 
v3
Comments
Nutan R 30-Aug-12 2:05am    
It gives me an error "The server tag is not well formed" :(
Kuthuparakkal 30-Aug-12 2:07am    
check now!

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