Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > generated imageButton does not receive click Event

Reply
Thread Tools

generated imageButton does not receive click Event

 
 
gabriel
Guest
Posts: n/a
 
      08-05-2005
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 !
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      08-05-2005
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

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke



"gabriel" <(E-Mail Removed)> wrote in message
news:42f32d97$0$18769$(E-Mail Removed)...
> 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 !



 
Reply With Quote
 
 
 
 
gabriel
Guest
Posts: n/a
 
      08-05-2005
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ImageButton event doesn't fire but Button event does suzanne.boyle@gmail.com ASP .Net 4 06-13-2007 09:19 PM
Does not Posts Back the form on ImagebUtton click asp.net KhurramAtk ASP .Net Security 1 03-26-2005 06:11 AM
raising a Click or Command event on an ImageButton click control James Tsao ASP .Net Web Controls 0 10-25-2004 09:17 PM
ImageButton control fails to capture click event when alternate textis displayed Benjamin Gavin ASP .Net 3 09-28-2004 12:02 AM
Click event on an ImageButton column =?Utf-8?B?SiBNY0Q=?= ASP .Net 4 02-24-2004 10:21 AM



Advertisments