LoadControl and PostBack

C

Craig Buchanan

I am trying to build a tabbed-style interface to capture information about a
person. I have one control that captures info about the person and a second
webuser control that captures information about the departments to which the
person is assigned. When a user clicks a tab, the appropriate WUC is
displayed.

Currently, I'm loading the appropriate control when Not IsPostBack. This
makes sense when a querystring is used to access the aspx page or to change
tabs.

Unfortunately, when one of the WUC posts back, the WUC is not loaded.
Obviously, I can't update any information in the WUC as it isn't there.

Does a control need to be loaded during postbacks as well? I suppose I
could always load both controls and hide the inactive one, but this seems
like an unnecessary waste of resources. Is there a better way?

Thanks,

Craig Buchanan
 
K

Kevin Spencer

Hi Craig,

ASP.Net is stateless, which means that each Request occurs "in a vacuum" so
to speak. Once an ASPX page is processed, it is unloaded from memory.
Therefore, dynamically-added Controls must be dynamically added with each
PostBack.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 

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

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top