Event Fires after CreateChildControls

Discussion in 'ASP .Net Building Controls' started by John Bankhead, Jul 15, 2005.

  1. I have created a C# control that creates its objects within
    CreateChildControls. One of those objects is a button which I have attached
    to a command event. The command event fires after CreateChildControls runs,
    but I want the clicking of the button to have an effect on what items
    CreateChildControls creates. Is this possible? Obviously I can make this
    happen by setting a value on an object on the client side and reading it in
    CreateChildControls. But still, I am curious.


    --
    John Bankhead
     
    John Bankhead, Jul 15, 2005
    #1
    1. Advertising

  2. John Bankhead

    Teemu Keiski Guest

    Hi,

    you could do this in Click event handler (of the Button) or have customized
    routine to do it (assuming we are inside the custom control logic all the
    time)

    a) Clear child controls collection by calling Controls.Clear() and clear
    child state by calling ClearChildViewState()
    b) set ChildControlsCreated to false
    c) Do the stuff that has impact on child control creation
    d) finally call EnsureChildControls which willl call CreateChildControls (it
    does that when ChildControlCreated flag is false)

    So simply saying, you recreate the control in such scenario.

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke
     
    Teemu Keiski, Jul 18, 2005
    #2
    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. Max2006
    Replies:
    2
    Views:
    1,618
    Walter Wang [MSFT]
    Sep 19, 2007
  2. Mark Sisson

    CreateChildControls Event before Click Event

    Mark Sisson, Jul 17, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    389
    Victor Garcia Aprea [MVP]
    Jul 17, 2003
  3. Mark Sisson

    CreateChildControls Event before Click Event

    Mark Sisson, Jul 17, 2003, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    209
    Victor Garcia Aprea [MVP]
    Jul 17, 2003
  4. createchildcontrols fires before click event

    , Jun 26, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    214
    Tom John
    Jul 4, 2007
  5. Replies:
    3
    Views:
    1,022
Loading...

Share This Page