By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,825 Members | 1,218 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,825 IT Pros & Developers. It's quick & easy.

Handling Events For Dynamically Created Buttons

P: n/a
I have LinkButtons that are dynamically created in one of the PostBack
events. They must be created in the PostBack event because one of the
variables required to determine which ones to create comes from the event
arguments. Because the LinkButtons are not created in the Init event, they
will not exist when I click them to perform a postback. How do I handle the
events for these LinkButtons? I appreciate any help you can give. Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Feb 25 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Feb 25, 11:38 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I have LinkButtons that are dynamically created in one of the PostBack
events. They must be created in the PostBack event because one of the
variables required to determine which ones to create comes from the event
arguments. Because the LinkButtons are not created in the Init event, they
will not exist when I click them to perform a postback. How do I handle the
events for these LinkButtons? I appreciate any help you can give. Thanks.
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/
Hi...

Once you have created the controls... constract a viewstate variable
or session variable to that you can know that dynamically created
links are exists...
After each post back "on Init" first determine wheither dynamically
added controls exists or not... if exists do create the dynamically
added links again...
asp.net will automatically map the event and fire it...
but make sure the control ids remain same...
Masudur
www.munna.shatkotha.com
www.shatkotha.com
Feb 25 '08 #2

P: n/a
That would be fine if the number of dynamically created LinkButtons had a
maximum, but it doesn't. Therefore, I would not know how many to create in
the Init event. Also, is there any site you can give me that has a good
example of how to do this? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Masudur" <mu*****@gmail.comwrote in message
news:7b**********************************@e25g2000 prg.googlegroups.com...
On Feb 25, 11:38 am, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>I have LinkButtons that are dynamically created in one of the PostBack
events. They must be created in the PostBack event because one of the
variables required to determine which ones to create comes from the event
arguments. Because the LinkButtons are not created in the Init event,
they
will not exist when I click them to perform a postback. How do I handle
the
events for these LinkButtons? I appreciate any help you can give. Thanks.
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/

Hi...

Once you have created the controls... constract a viewstate variable
or session variable to that you can know that dynamically created
links are exists...
After each post back "on Init" first determine wheither dynamically
added controls exists or not... if exists do create the dynamically
added links again...
asp.net will automatically map the event and fire it...
but make sure the control ids remain same...
Masudur
www.munna.shatkotha.com
www.shatkotha.com

Feb 26 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.