Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Problems adding functionallity to dynamically created buttons


Message #1 by "Morgan Bell" <morgyb@h...> on Wed, 19 Jun 2002 00:00:44
I am creating (in VB) a web app that populates a Directory Tree from a 
supplied directory on the server.  I simply want to click the name of the 
file and have the program pull that into a text field, but no dynamically 
created onClick event seems to work for me.  I have tried <span> tags, 
buttons, and literals, but seem to have no luck.  Can anyone help me?
Message #2 by david@p... on Tue, 25 Jun 2002 02:29:25
> I am creating (in VB) a web app that populates a Directory Tree from a 
s> upplied directory on the server.  I simply want to click the name of 
the 
f> ile and have the program pull that into a text field, but no 
dynamically 
c> reated onClick event seems to work for me.  I have tried <span> tags, 
b> uttons, and literals, but seem to have no luck.  Can anyone help me?

I have the same or similar problem.  From a listbox click I dynamically 
create some labels, related text boxes and an OK button.  Then I hook up 
the button's click event.  However, the event never fires.  When I did the 
dynamic stuff inside Page_Load the event fired but I need these as 
separate subs and that is not working.  Please let me know if you find a 
solution.  I'll do likewise.

David
Message #3 by david@p... on Tue, 25 Jun 2002 03:45:20
Morgan,

This site 
http://www.dotnet247.com/247reference/msgs/3/17094.aspx
has 2 variations to the solution.  The declaration of the control and its 
event wiring is done either in Page_Load or Page_Init event.  One writer 
says 
"NB The control has to be re-created when the post backs is done or
else the event will not fire. I suggest creating the control within
the Page_Init event."

Hope this helped.

David
Message #4 by Feduke Cntr Charles R <FedukeCR@m...> on Tue, 25 Jun 2002 08:51:13 -0400
David,

> the button's click event.  However, the event never fires.  When I did the

> dynamic stuff inside Page_Load the event fired but I need these as 
> separate subs and that is not working.  Please let me know if you find a 
> solution.  I'll do likewise.

	I think your control needs to implement IPostBackEventHandler which
requires you implement LoadPostData(...) and RaisePostDataChangedEvent().
When you dynamically add the control to the page, also
Page.RequiresPostBackEvent(theControl) as well.  Let me know if this works.

- Chuck

-----Original Message-----
From: david@p... [mailto:david@p...]
Sent: Monday, June 24, 2002 10:29 PM
To: ASP+
Subject: [aspx] Re: Problems adding functionallity to dynamically
created buttons


> I am creating (in VB) a web app that populates a Directory Tree from a 
s> upplied directory on the server.  I simply want to click the name of 
the 
f> ile and have the program pull that into a text field, but no 
dynamically 
c> reated onClick event seems to work for me.  I have tried <span> tags, 
b> uttons, and literals, but seem to have no luck.  Can anyone help me?

I have the same or similar problem.  From a listbox click I dynamically 
create some labels, related text boxes and an OK button.  Then I hook up 
the button's click event.  However, the event never fires.  When I did the 
dynamic stuff inside Page_Load the event fired but I need these as 
separate subs and that is not working.  Please let me know if you find a 
solution.  I'll do likewise.

David
Message #5 by "David Adames" <david@p...> on Tue, 25 Jun 2002 16:47:50 -0400
Chuck,

My VS.NET has become corrupted and I'm having problems reinstalling.  When I
do reinstall I'll try out your suggestion.

Thanks,
David

-----Original Message-----
From: Feduke Cntr Charles R [mailto:FedukeCR@m...]
Sent: Tuesday, June 25, 2002 8:51 AM
To: ASP+
Subject: [aspx] Re: Problems adding functionallity to dynamically crea
ted buttons


David,

> the button's click event.  However, the event never fires.  When I did the

> dynamic stuff inside Page_Load the event fired but I need these as
> separate subs and that is not working.  Please let me know if you find a
> solution.  I'll do likewise.

	I think your control needs to implement IPostBackEventHandler which
requires you implement LoadPostData(...) and RaisePostDataChangedEvent().
When you dynamically add the control to the page, also
Page.RequiresPostBackEvent(theControl) as well.  Let me know if this works.

- Chuck

-----Original Message-----
From: david@p... [mailto:david@p...]
Sent: Monday, June 24, 2002 10:29 PM
To: ASP+
Subject: [aspx] Re: Problems adding functionallity to dynamically
created buttons


> I am creating (in VB) a web app that populates a Directory Tree from a
s> upplied directory on the server.  I simply want to click the name of
the
f> ile and have the program pull that into a text field, but no
dynamically
c> reated onClick event seems to work for me.  I have tried <span> tags,
b> uttons, and literals, but seem to have no luck.  Can anyone help me?

I have the same or similar problem.  From a listbox click I dynamically
create some labels, related text boxes and an OK button.  Then I hook up
the button's click event.  However, the event never fires.  When I did the
dynamic stuff inside Page_Load the event fired but I need these as
separate subs and that is not working.  Please let me know if you find a
solution.  I'll do likewise.

David



  Return to Index