I have this popup (open) link
<a href="modal.html" target="_blank" onclick="openMyModal('modal.html'); return false;">Click here to open</a>
Its works fine, but how can i use this OnClick event on a Asp:ImageButton !?
<asp:ImageButton runat="server" ID="btnSubscribe" ImageUrl="~/add/image/btntilmeld.png"></asp:ImageButton>
If i add the OnClick to the Asp:ImageButton i get this error
For the asp.net server controls, OnClick fires the server event. To fire the client event, you have to use OnClientClick. OnClick will fire the client side event only for HTML controls, not for asp.net controls.
OnClientClick is working, its just show the modal popup in the upper left corner now, and not center.
How do i add the target="_blank" til the asp:imagebutton !?
siraero
Member
419 Points
604 Posts
how can i use an A href OnClick on an Asp:Imagebutton
Apr 06, 2012 08:55 PM|LINK
Hi
I have this popup (open) link
<a href="modal.html" target="_blank" onclick="openMyModal('modal.html'); return false;">Click here to open</a>
Its works fine, but how can i use this OnClick event on a Asp:ImageButton !?
<asp:ImageButton runat="server" ID="btnSubscribe" ImageUrl="~/add/image/btntilmeld.png"></asp:ImageButton>
If i add the OnClick to the Asp:ImageButton i get this error
<asp:ImageButton runat="server" ID="btnSubscribe" ImageUrl="~/add/image/btntilmeld.png" onclick="openMyModal('modal.html'); return false;"></asp:ImageButton>BC30456 openMyModal is not a member of ASP.masterpage_master
shivalthakur
Participant
1837 Points
531 Posts
Re: how can i use an A href OnClick on an Asp:Imagebutton
Apr 07, 2012 03:35 AM|LINK
hitry this<asp:ImageButton runat="server" ID="btnSubscribe" ImageUrl="~/add/image/btntilmeld.png" OnClientClick="openMyModal('modal.html'); return false;"></asp:ImageButton>Response.Write("Success");
Best Of Luck
Shival Thakur
all-alone808
Member
290 Points
75 Posts
Re: how can i use an A href OnClick on an Asp:Imagebutton
Apr 07, 2012 07:25 AM|LINK
you can place your asp:hyperlink and then image like that
<asp:hyperlink onclick="openpopup(this)">
<image/>
</asp:hyperlink>
ramiramilu
All-Star
95413 Points
14106 Posts
Re: how can i use an A href OnClick on an Asp:Imagebutton
Apr 07, 2012 08:47 AM|LINK
not onclick, you need to assign it to OnClientClick - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.imagebutton.onclientclick.aspx
Thanks,
JumpStart
Ruchira
All-Star
42943 Points
7024 Posts
MVP
Re: how can i use an A href OnClick on an Asp:Imagebutton
Apr 07, 2012 10:20 AM|LINK
Hello,
For the asp.net server controls, OnClick fires the server event. To fire the client event, you have to use OnClientClick. OnClick will fire the client side event only for HTML controls, not for asp.net controls.
My Tech blog | My YouTube ChannelPlease 'Mark as Answer' if this post helps you.siraero
Member
419 Points
604 Posts
Re: how can i use an A href OnClick on an Asp:Imagebutton
Apr 07, 2012 08:24 PM|LINK
OnClientClick is working, its just show the modal popup in the upper left corner now, and not center.
How do i add the target="_blank" til the asp:imagebutton !?