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
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