Custom server Controls event handling (Parent/Child)

A

Arulraja

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
 
V

Victor Garcia Aprea [MVP]

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

Arulraja

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top