Databinding in tag problem!

H

Henk

Hello,
I have a problem, with a gridview, i won't a javascript function,
OpenPopUP(sCMD,bBoolean,iregID) to run when a image is clicked. So i add an
onclick event to the img tag like this. (this is in the itemtemplate off the
gridview)

<img src="img/edit.gif" style="width: 18px; height: 18px"
onclick="OpenPopUp('EDIT','true',<%#Container.DataItem("RegistrationID")%>)"
/>

this works fine, but why isnt the folowing code working:

<asp:ImageButton ID="btnEdit" runat="server"
OnClientClick="OpenPopUp('Edit',
'true',<%#Container.DataItem("RegistrationID")%>)" ImageUrl="img/edit.gif"
/>

I get some kind of error, server tag not well formed??
Can someone help me??

Thanks in regard..
 
P

Patrick Jox

I think this is a problem with the quotation marks. I would try something
like this.

OnClientClick='OpenPopUp("Edit",
"true",<%#Container.DataItem("RegistrationID")%>)'

Not sure but hope this helps
Patrick
 
B

bruce barker \(sqlwork.com\)

you have two problems. binding expressing must be the only specification of
an attribute value:

<asp:ImageButton ID="btnEdit" runat="server"
OnClientClick='<%# "OpenPopUp('Edit', 'true'," +
Container.DataItem("RegistrationID") + ")" %>'
ImageUrl="img/edit.gif"
/>

also the ImageButton will perform a browser postback, so you must cancel the
postback unless you want it.

-- bruce (sqlwork.com)
 
V

vMike

Henk said:
Hello,
I have a problem, with a gridview, i won't a javascript function,
OpenPopUP(sCMD,bBoolean,iregID) to run when a image is clicked. So i add an
onclick event to the img tag like this. (this is in the itemtemplate off the
gridview)

<img src="img/edit.gif" style="width: 18px; height: 18px"
onclick="OpenPopUp('EDIT' said:
/>

this works fine, but why isnt the folowing code working:

<asp:ImageButton ID="btnEdit" runat="server"
OnClientClick="OpenPopUp('Edit',
'true',<%#Container.DataItem("RegistrationID")%>)" ImageUrl="img/edit.gif"
/>

I get some kind of error, server tag not well formed??
Can someone help me??

Thanks in regard..
Try something like this.

OnClientClick=<%# "OpenPopUp('Edit', 'true'," +
Container.DataItem("RegistrationID") + ")" %>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top