generated imageButton does not receive click Event

G

gabriel

greetings,

I am currently stucked with the following problem :

I got userControl which is programmatically fed ImageButtons. Then, in
his render method, it creates a table containing the imagebuttons.

When I Click on the imageButton, the browser should be redirected to
some url.
The thing is a gallery, as you might have guessed.

here is the method used to feed the control :

public void addImageButton(ImageButton image)
{
if (this.imageButtonList == null)
this.imageButtonList = new ArrayList();
this.imageButtonList.Add(image);
image.CommandArgument = "1";
image.CommandName = "gotoanyway";
image.Command += new
System.Web.UI.WebControls.CommandEventHandler(this.processImageCommand);
image.Click += new System.Web.UI.ImageClickEventHandler
(this.processImageClick);
}

I played with CommandEventHandler and ImageClickEventHandler but got no
result. In fact, the event is not even captured.

What I think is that the event is sent to the page but since she has no
ImageClickEventHandler, the event is just lost.

Is it possible to delegate the processing of the event from the page to
the imageButton ?
I do not know much yet about the delegate pattern, thus my question :)

many thanks for your input !
 
T

Teemu Keiski

Hi,

it is because creating dynamical controls is too late in that phase(render)
because postback events are "detected" after Page_load and then raised right
after that. Dynamical control needs to be recreated on postback at Page_Load
at the latest so that it can raise events during that request (e.g recreated
in Load on that request during which control is expected to raise postback
events)

You can check this thread also for explanation:
http://forums.asp.net/1008148/ShowPost.aspx
 
G

gabriel

Dynamical control needs to be recreated on postback at Page_Load
at the latest so that it can raise events during that request (e.g recreated
in Load on that request during which control is expected to raise postback
events)

You can check this thread also for explanation:
http://forums.asp.net/1008148/ShowPost.aspx

Yes thank you very much !
that was it, I needed to recreate the stuff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top