I am in need of replacing an ImageButton
within a GridView
ItemTemplate
with an icon that is defined in a CSS style.
My usual approach would be to replace the ImageButton with a hidden button and then use JQuery to trigger a click event on the hidden button. Here's an example:
<a class="btn" href="#" onclick="Utils.ClickButton('<%= btnTest.ClientID %>');"><i class="icon"> </i>Download to Excel</a>
<asp:Button ID="btnTest" CssClass="btn" ToolTip="Download to Excel" runat="server" />
However, this method does not seem to work for ImageButtons that have a command argument to put the grid into edit mode. When I try to implement the above solution, I receive a runtime error stating that btnTest cannot be found.
Therefore, what I require is:
<asp:ImageButton ID="btnDelete" CommandArgument='<%#Eval("ID")%>' ToolTip="Delete" runat="server" CommandName="Delete"
ImageUrl="/images/delete.png" />
To appear like so:
<a class="btn" href="#" onclick="Utils.ClickButton('<%= btnTest.ClientID %>');"><i class="icon"> </i></a>