Because the EventHandler of ImageButton is not System.EventHan dler.
You have to change at InitializeCompo nent(), from ExpandButton.On Click +=
new System.EventHan dler(ExpandButt on_click) to ExpandButton.Cl ick += new
ImageClickEvent Handler(ExpandB utton_click);
And then the function declaration to private void
ExpandButton_cl ick(object sender, System.Web.UI.I mageClickEventA rgs e)
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^
"tshad" <ts**********@f tsolutions.com> ¦b¶l¥ó
news:%2******** ********@TK2MSF TNGP15.phx.gbl ¤¤¼¶¼g...
"Ken Cox [Microsoft MVP]" <BA************ @sympatico.ca> wrote in message
news:uc******** ******@TK2MSFTN GP12.phx.gbl... Hi Tom.
If you're talking about the server-side Click event then the signature
would look like this:
Private Sub ImageButton1_Cl ick _
(ByVal sender As System.Object, _
ByVal e As System.Web.UI.I mageClickEventA rgs) _
Handles ImageButton1.Cl ick
End Sub
Is that what you meant?
Here is an asp:Button line with the onClick method
<asp:Button ID="CollapseAll " text="Collapse All"
runat="server" Font-Size="2" onClick="collap seAll_click" Width="16"
Height="16" AlternateText=" Click here to see
details"></asp:Button>&nbs p;
If you take the following line:
<asp:ImageButto n ID="ExpandButto n" runat="server"
Font-Size="2" ImageUrl="../images/expand.jpg" Width="16" Height="16"
CommandName="Se lect" AlternateText=" Click here to see
details"></asp:ImageButton >
And change it to:
<asp:ImageButto n ID="ExpandButto n"
onClick="Expand Button_click" runat="server" Font-Size="2"
ImageUrl="../images/expand.jpg" Width="16" Height="16"
CommandName="Se lect" AlternateText=" Click here to see details"></asp:ImageButton >
You get the following message:
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: BC30408: Method 'Public Sub
ExpandButton_cl ick(sender As Object, e As System.EventArg s)' does not have
the same signature as delegate 'Delegate Sub ImageClickEvent Handler(sender
As Object, e As System.Web.UI.I mageClickEventA rgs)'.
Thanks,
Tom
Ken
Microsoft MVP [ASP.NET]
"tshad" <ts**********@f tsolutions.com> wrote in message
news:OT******** ******@TK2MSFTN GP10.phx.gbl...I was trying to change my asp:button to asp:ImageButton , but got a
messagesaying that ImageButton does not have an onClick function.
How do I get the ImageButton call a function?
Thanks,
Tom.