I have an asp.net linkbutton
, which contains the OnClientClick
property, however the function within the OnClientClick
never gets called, it directly jumps to OnClick
function.
Below are the 2 ways I am using LinkButton as:
<asp:LinkButton ID="btn" CssClass="button" Text="Browse Thumbnail" runat="server"
OnClientClick="return confirm('Are you sure you want to delete?');">
</asp:LinkButton>
and:
<asp:LinkButton ID="lnkDelete" runat="server"
OnClientClick="return confirm('Are you sure you want to delete this slide?');"
CommandName="DeleteThumbnail" CommandArgument='<%# Container.DataItemIndex %>'>
<asp:Image ImageUrl="~/images/delete.gif" ID="imgDelete" runat="server"></asp:Image>
</asp:LinkButton>
Both of the approaches does not works.
Can anyone please provide some solution for the same.
There is most probably some other page element that is preventing this event from being fired.
Do you have any other page elements that might interfere? Have you tried removing all other page elements but this one? Do you have some AJAX calls that might interfere? Have you tried this with a simple html element (not asp.net)?
You are most probably doing everything fine in your link button but it seems like problem is elsewhere.