473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Change Onclick event dynamically for an ImageButton control

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 :

<asp:ImageButton id="id1" Visible="false" runat="server"
EnableViewState="false" CausesValidation="false" ImageAlign="AbsMiddle" />

Déclaration in Code Behind :

...
Protected WithEvents id1 As ImageButton
...

Sub Page_Load...

If .. mon test
id1 .Visible=True
AddHandler id1.onClick, AddressOf doExcelExport
....
End Sub
The error :

Compiler Error Message: BC30390:
'System.Web.UI.WebControls.ImageButton.Protected Overridable Sub OnClick(e
As System.Web.UI.ImageClickEventArgs)' is not accessible in this context
because it is 'Protected'.
If someone can explain me the problem et show me how to do that ..

thanks a lot
fabrice.

Sep 21 '06 #1
1 2859
Add to attributes:

ImageButton1.Attributes.Add("onClick", "alert('you clicked me!');");
--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*************************************************
Think outside of the box!
*************************************************
"fabrice" <em******@test.comwrote in message
news:us****************@TK2MSFTNGP05.phx.gbl...
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 :

<asp:ImageButton id="id1" Visible="false" runat="server"
EnableViewState="false" CausesValidation="false" ImageAlign="AbsMiddle" />

Déclaration in Code Behind :

..
Protected WithEvents id1 As ImageButton
..

Sub Page_Load...

If .. mon test
id1 .Visible=True
AddHandler id1.onClick, AddressOf doExcelExport
...
End Sub
The error :

Compiler Error Message: BC30390:
'System.Web.UI.WebControls.ImageButton.Protected Overridable Sub OnClick(e
As System.Web.UI.ImageClickEventArgs)' is not accessible in this context
because it is 'Protected'.
If someone can explain me the problem et show me how to do that ..

thanks a lot
fabrice.

Sep 21 '06 #2

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

Similar topics

3
by: Jim Mitchell | last post by:
I have some code behind that generates 10 imagebutton controls.... I can not seem to figure out how to trap the onclick event for each image and determine which image was clicked. Can someone...
0
by: luca | last post by:
Hi all. My problem is that I can't handle events raised from child components within a composite server control when the control is created dynamically. Everything works fine if the same control...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
6
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...
0
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...
4
by: Jordan | last post by:
I need to dynamically add an ImageButton control to a user control and and do some server-side processing when the user clicks it. While I the ImageButton is added to the user control at runtime,...
2
by: Steve | last post by:
Hi, I have a dynamically created ImageButton in a custom control, and I can't get the control to handle the ImageButton Click event. I see the control in the Page.Request.Form.AllKeys collection,...
7
by: rsaffy | last post by:
I am having trouble with my dynamically created button's event handling. I read that the buttons need to be recreated on every trip to the server, but how exactly do you do that when the datagrid...
1
by: cradius | last post by:
I've got a custom user control, with a DataList, that is dynamically added to the page. In the DataList is an ImageButton that, when clicked, fires off the ItemCommand event of the DataList and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.