Problems populating a user control with dynamic controls

M

Mark Power

Hi everyone,

I'm working on a user control that will dynamically generate a series
of controls based on the contents of an array passed back from an API
call, the problem is that I cant seem to get the usercontrol to
populate with the dynamic controls whenever the page the user control
is on is first loaded.

I had the code that creates the dynamic controls in a function that was
called in the page load event of the user control, however this led to
some problems whenever a postback was performed, i.e. the controls were
destroyed before i had a chance to collect the values from them.

I came across an article on the Microsoft support site that advised
that dynamic controls should be created in the OnInit event of the
page, I changed my control to do this, when I did the controls are no
longer created on the page load, but whenever a postback is initially
performed.

I noticed that this is because the oninit call is made on the control
before the page load event is fired in the page that contains the
control, this meant that the first time my page is loaded the call to
get the array that governs the control creation is not fired.

Basically my question is, is there any way that I can fire the code in
the page_load event of the page that contains the user control before
the oninit event of a user control is fired?
Any and all help is greatly appreciated.

Thanks
Mark
 

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

No members online now.

Forum statistics

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

Latest Threads

Top