Problems with Nesting custom controls

Discussion in 'ASP .Net Web Controls' started by Nauman, May 8, 2006.

  1. Nauman

    Nauman Guest

    Hi All,

    I've created two custom composite controls.
    The first one is just a composition of a dropdown and a button. The user is
    supposed to select a list item and click the button so that I can get the
    value to perform server-side processing. This works just fine.

    Where as the second one is a much larger control with many other controls
    including the first one. I've instantiated the first control in the Second
    one's CreateChildControls method. When I select a value in the embedded
    (first control) control's dropdown list and click its associated button,
    everything seems to work fine except that, I loose the selected index of the
    nested(first control's) control's listbox.

    PS: One more thing worth mentioning is that the list values for my first
    control are populated in the OnLoad event of the control itself.

    protected override void OnLoad(EventArgs e)
    {
    EnsureChildControls();
    if(!Page.IsPostBack)
    {
    GetJobStates();
    if(StateList != null)
    {
    ddlState.Items.Clear();
    for(int iCtr = 0; iCtr < StateList.Length; iCtr++)
    {
    ddlState.Items.Add(StateList[iCtr]);
    }
    }
    }
    base.OnLoad (e);
    }

    If I remove the "if(!Page.IsPostBack)" check then the second control works
    fine with the embedded first control, but the first control doesn't works
    independently (without nesting/embedding)

    Any Ideas???

    Regards
    Nauman
    Nauman, May 8, 2006
    #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. Gramps
    Replies:
    1
    Views:
    829
  2. Phil Townsend

    nesting controls

    Phil Townsend, Mar 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    343
    Phil Townsend
    Mar 8, 2005
  3. John Kotuby
    Replies:
    2
    Views:
    362
    John Kotuby
    Jun 4, 2007
  4. rodchar
    Replies:
    0
    Views:
    379
    rodchar
    Nov 26, 2007
  5. Trans
    Replies:
    10
    Views:
    286
    Sean O'Halpin
    Sep 16, 2005
Loading...

Share This Page