473,748 Members | 5,429 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ImageButton has not onClick method

I was trying to change my asp:button to asp:ImageButton , but got a message
saying that ImageButton does not have an onClick function.

How do I get the ImageButton call a function?

Thanks,

Tom.
Nov 18 '05 #1
3 6298
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?

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 message
saying that ImageButton does not have an onClick function.

How do I get the ImageButton call a function?

Thanks,

Tom.


Nov 18 '05 #2
"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;&nbsp;

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 message
saying that ImageButton does not have an onClick function.

How do I get the ImageButton call a function?

Thanks,

Tom.

Nov 18 '05 #3
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;&nbsp;

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.


Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3640
by: Chuck Hartman | last post by:
I've been trying to add an ImageButton object to a Calendar table cell, but so far I am unable to handle the Command event from that button in my form's code behind. Below is an example of what I am trying to do. The ImageButton that is on the form handles its Command event just fine, but the ImageButton that is added to the cell does not handle the event. Am I doing something wrong, or is not possible to add server controls to a calendar...
5
6173
by: J McD | last post by:
Hi I have a DataGrid with an ImageButton column. When I click on an imagebutton I get a postback but it doesn't run the OnImgBtnClick method. I can actually comment out the line where I add this Click event to the ImageButton Column and it makes no difference, I still get a postback. This is driving me crazy...something seems to be causing an OnClick postback and it isn't my Click event I've included the code below....any help will be...
6
22133
by: ruca | last post by:
Hi gurus, I have a imagebutton in my WebForm, and I want that when I click (mouse down) on her the imagebutton change image and when I "unclick" (mouse up) change to the original image. Basically I want to know how can I have the mousedown and mouseup buttons events. I think that I have to do this in JavaScript. Can you help me on this?
0
1139
by: Mick | last post by:
Hi (again ^^) In my ItemDataBound function, I dynamically create an ImageButton. I add to it an onclick event. Anyway, when clicking my imagebutton, I don't raise the onclick event ! Any help will be appreciated ^^ ***** System.Web.UI.WebControls.ImageButton NewImg = new ImageButton();
2
1964
by: Bruce | last post by:
I have a button on a form that creates multiple ImageButtons; I want each ImageButton's click event to then redirect to another URL. From doing some research, I understand this has to do with ImageButtons (and their handlers) not being re-assigned on postback, but how do I accomplish the above? .... ImageButton ib = new ImageButton(); ib.Width = 100; ib.Height = 80; ib.ImageUrl = @"http://mysite.com/images/image1.jpg";
1
1285
by: Franck | last post by:
Heelo, I'm looking for a component that allow creating a ImageButton slighlty imporved as I wish It could change backggrtound image with the following event; onMouseOut onMouseOver onClick I've done it done it that way using javascirpt in the html code: ----------------------------------------------------- <a id="A1" href="#"
1
2879
by: fabrice | last post by:
Hello, I d like to modify the Onclik Event of an ImageButton control in code behind. But when i do it , i get an error. This is ma code : The control is the pasx page :
2
14097
by: dperren | last post by:
At current, I have a set of dynamically generated image buttons, which are created with this (excert) of code: TableCell tasks = new TableCell(); while (reader.Read()) { ImageButton button = new ImageButton(); button.Click += new System.Web.UI.ImageClickEventHandler(taskButton_Click); button.ImageUrl = "Images/task.gif"; button.BorderWidth = 2;
1
1641
by: Jonathan Wood | last post by:
I'm trying to convert some old HTML pages to ASP.NET. I'm experimenting with code that responds to a button click. But although the mouse turns into a hand pointer when it is over the button, absolutely nothing happens when I click it. Does anyone know if this could have anything to do the fact that my button is on a master page (along with the handler)? That shouldn't make any difference should it?
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9316
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2777
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2211
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.