Problems populating a user control with dynamic controls

Discussion in 'ASP .Net Web Controls' started by Mark Power, Oct 22, 2004.

  1. Mark Power

    Mark Power Guest

    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
     
    Mark Power, Oct 22, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sm9obiBOaW5hbg==?=

    populating dynamic user control (ascx)

    =?Utf-8?B?Sm9obiBOaW5hbg==?=, Sep 23, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    4,773
    =?Utf-8?B?Sm9obiBOaW5hbg==?=
    Sep 24, 2004
  2. Replies:
    5
    Views:
    5,586
  3. Faizan Ahmed
    Replies:
    1
    Views:
    288
    John Saunders
    Jan 4, 2005
  4. PeteZ

    Populating web Controls inmedded in a User Control

    PeteZ, Dec 5, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    99
    PeteZ
    Dec 6, 2004
  5. Faizan Ahmed
    Replies:
    1
    Views:
    366
    John Saunders
    Jan 4, 2005
Loading...

Share This Page