Custom server Controls event handling (Parent/Child)

Discussion in 'ASP .Net Building Controls' started by Arulraja, Oct 17, 2003.

  1. Arulraja

    Arulraja Guest

    Hi,

    Hello,

    I have a question regarding Custom server Controls event handling.
    The problem I am facing is, I have created 2 Controls say
    BrandContainer and FamilyContainer.

    1. The FamilyConatiner renders a table with a Button Control on it.
    2. The BrandContainer renders a table with a FamilyContainer on it.
    3. In the FamilyContainer-> Button's OnClick event I wrote some
    validations and do some business logics.
    4. Then it should renders the page again with the changed value.

    But the problem is, if I click the button, it calls the
    BrandContainer's CreateChildControls method.Then it build all the
    child controls, including the FamilyContainer, then it call's the
    OnClick event of the FamilyContainer.
    So, my page renders before all the validations and business logics
    have done.

    I don't know how to handle this. If it fires the onClick event of the
    child control first then I can handle the Parents CreateChildControls
    Method without any problem.

    Thanks for ur help.

    -Livingston
    Arulraja, Oct 17, 2003
    #1
    1. Advertising

  2. Hi Arulraja,

    The called methods and order of events you're seeing is expected. Controls
    are re-created before events are processed, then in response to an event you
    may want to change some of the values for your child controls or maybe
    modify the control tree itself.

    > So, my page renders before all the validations and business logics
    > have done.


    Not sure what you mean by this; you've some events prior to rendering (ie.
    PreRender) that you could use to modify your control before its rendered.

    It would really help if you could provide some more detail -maybe with some
    code- on your specific problem.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    and not by private mail.

    "Arulraja" <> wrote in message
    news:...
    > Hi,
    >
    > Hello,
    >
    > I have a question regarding Custom server Controls event handling.
    > The problem I am facing is, I have created 2 Controls say
    > BrandContainer and FamilyContainer.
    >
    > 1. The FamilyConatiner renders a table with a Button Control on it.
    > 2. The BrandContainer renders a table with a FamilyContainer on it.
    > 3. In the FamilyContainer-> Button's OnClick event I wrote some
    > validations and do some business logics.
    > 4. Then it should renders the page again with the changed value.
    >
    > But the problem is, if I click the button, it calls the
    > BrandContainer's CreateChildControls method.Then it build all the
    > child controls, including the FamilyContainer, then it call's the
    > OnClick event of the FamilyContainer.
    > So, my page renders before all the validations and business logics
    > have done.
    >
    > I don't know how to handle this. If it fires the onClick event of the
    > child control first then I can handle the Parents CreateChildControls
    > Method without any problem.
    >
    > Thanks for ur help.
    >
    > -Livingston
    Victor Garcia Aprea [MVP], Oct 19, 2003
    #2
    1. Advertising

  3. Arulraja

    Arulraja Guest

    Hi Victor ,

    Thanks for your reply.

    Actually, I fixed the problem, I override the OnBubbleEvent of the
    Parent control, in that event I call the Parent Controls
    CreateChildControl method.
    That fix the problem. But I am not sure it is a right way to handle or
    not.

    Thanks
    Arul

    "Victor Garcia Aprea [MVP]" <> wrote in message news:<#>...
    > Hi Arulraja,
    >
    > The called methods and order of events you're seeing is expected. Controls
    > are re-created before events are processed, then in response to an event you
    > may want to change some of the values for your child controls or maybe
    > modify the control tree itself.
    >
    > > So, my page renders before all the validations and business logics
    > > have done.

    >
    > Not sure what you mean by this; you've some events prior to rendering (ie.
    > PreRender) that you could use to modify your control before its rendered.
    >
    > It would really help if you could provide some more detail -maybe with some
    > code- on your specific problem.
    >
    > --
    > Victor Garcia Aprea
    > Microsoft MVP | ASP.NET
    > Looking for insights on ASP.NET? Read my blog:
    > http://obies.com/vga/blog.aspx
    > To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    > and not by private mail.
    >
    > "Arulraja" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > Hello,
    > >
    > > I have a question regarding Custom server Controls event handling.
    > > The problem I am facing is, I have created 2 Controls say
    > > BrandContainer and FamilyContainer.
    > >
    > > 1. The FamilyConatiner renders a table with a Button Control on it.
    > > 2. The BrandContainer renders a table with a FamilyContainer on it.
    > > 3. In the FamilyContainer-> Button's OnClick event I wrote some
    > > validations and do some business logics.
    > > 4. Then it should renders the page again with the changed value.
    > >
    > > But the problem is, if I click the button, it calls the
    > > BrandContainer's CreateChildControls method.Then it build all the
    > > child controls, including the FamilyContainer, then it call's the
    > > OnClick event of the FamilyContainer.
    > > So, my page renders before all the validations and business logics
    > > have done.
    > >
    > > I don't know how to handle this. If it fires the onClick event of the
    > > child control first then I can handle the Parents CreateChildControls
    > > Method without any problem.
    > >
    > > Thanks for ur help.
    > >
    > > -Livingston
    Arulraja, Oct 20, 2003
    #3
    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. Arulraja
    Replies:
    3
    Views:
    1,357
    William F. Robertson, Jr.
    Oct 17, 2003
  2. Replies:
    0
    Views:
    193
  3. Tillman

    Make parent control event call child control event

    Tillman, May 21, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    281
    Tillman
    May 21, 2004
  4. Noel Dolan
    Replies:
    0
    Views:
    215
    Noel Dolan
    Jul 18, 2004
  5. Bitswapper
    Replies:
    5
    Views:
    118
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page