• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

changing an asp:image button to a asp:button

I have the following:





<asp:Button CssClass="blackButton2" ID="Submit" runat="server" Text="Register" OnClick="imgRegister_Click" Font-Bold="True"


it was working with OnClick before I change it to a button instead of an image button.

It does not like the onclick?
Server Error in '/OL_Web' Application.

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0123: No overload for 'imgRegister_Click' matches delegate 'System.EventHandler'

Source Error:


Line 293:          <td class="label" align="left" height="25">&nbsp;</td>
Line 294:          <td class="body" >
Line 295:           <asp:Button CssClass="blackButton2" ID="imgRegister" runat="server" Text="Register"  
Line 296:                  Font-Bold="True" onclick="imgRegister_Click" />
Line 297:          </td>

1 Solution
Did you keep the same code-behind event handler after the change?
Image click takes an argument of type ImageClickEventArgs, instead of the simple EventArgs taken by the button.
You need to change the button click event too in code behind page.

When you use imabage button the onclick event will be
Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
****************Your code***********
    End Sub

when you use normal button your code will look like
 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
*******************Your code*************
    End Sub
mathieu_cuprykAuthor Commented:
excellent lak.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now