Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Loading controls dynamically in ASP.Net

Reply
Thread Tools

Loading controls dynamically in ASP.Net

 
 
supvine@gmail.com
Guest
Posts: n/a
 
      03-22-2006
Hello,

I am developing a page that has several custom web user controls that
need to be loaded dynamically. Some of the controls are loaded based
on the action (button-click) of a different control in the parent page.
Currently what I have to do to make this work is set a session
variable to load/unload a particular control and do a Server.Transfer
to the page itself from the Button_Click event. Is this a good way of
loading controls dynamically or is there a better way to do this? I am
using ASP.Net 1.1. Thanks.

Regards

 
Reply With Quote
 
 
 
 
Varangian
Guest
Posts: n/a
 
      03-22-2006
didn't understand why are you using a Session variable!?

 
Reply With Quote
 
 
 
 
Varangian
Guest
Posts: n/a
 
      03-22-2006
didn't understand why are you using a Session variable!?

 
Reply With Quote
 
supvine@gmail.com
Guest
Posts: n/a
 
      03-22-2006
Let's say that I have a page called Test.aspx which contains a button
called Button1 that has a corresponding Button1_Click event handler.
Let's also say that I have a control called TestControl.ascx which
contains another button called Button2. TestControl is added
dynamically due to Button1 click. When Button1 is clicked the page
execution happens as follows:

- Page_Load
- Button1_Click

If I have code inside Button1_Click to dynamically add the TestControl,
the next time the page is reloaded due to some other actions, say as a
result of Button2_Click in TestControl, the TestControl itself is not
loaded anymore. So I needed to have the logic in the Page_Load event
to check for a session variable to check if the TestControl should be
loaded or not. That way the TestControl is loaded as long as the
session variable is "true". On Button1_Click I set session variable to
"true" and do a Server.Transfer to itself. The Page_Load event looks
for that session variable and if it is set to true it loads the user
control dynamically.

Is there a better way of doing this? Thank you very much.

 
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
Issues in ASP.NET 2.0 when dynamically loading user controls or asp.net web controls??? Bob Rock ASP .Net 1 09-17-2006 01:49 PM
Dynamically Loaded controls loading other controls =?Utf-8?B?V291dGVy?= ASP .Net 3 02-27-2006 07:25 PM
Loading controls dynamically + passing parameters Jill Graham ASP .Net 1 05-03-2004 04:20 PM
when loading user controls dynamically, problem on postback sonic_soul ASP .Net 0 08-14-2003 10:05 PM
Re: Loading/Unloading web user controls dynamically in code - Does this look right? Ben Miller [msft] ASP .Net 0 08-05-2003 05:57 AM



Advertisments