liptonIcedTea
Well-known member
- Joined
- Jan 18, 2007
- Messages
- 89
- Programming Experience
- 1-3
Hi,
This is a question on code design.
I have an application that uses the Box Model - as in that I have pages, and the pages are constructed by web controls all added within each other to get like a hierarchy of controls.
So for example, i may have a page that looks like this
page - webcontrol1 - webcontrol11 - webcontrol 111 - webcontrol 1111
- webcontrol 112
- webcontrol12 - webcontrol 121
- webcontrol2 - webcontrol21
like a treeview.
My question is that I've noticed that when I need one web control to speak to another, and they are on different parts of the page, i pretty much have to raise an event, and cascade it up all the parent web controls to the page level, then cascade it back up the webcontrols till i get to the destination web control.
Eg. if WebControl1111 needs to speak to WebControl21, I have to raise an event in 111, then 11, then 1, then the page, then 2, then 21
This creates a lot of repetive coding of event handling classes that pretty much just raise another event.
My question is, is there a better way to do this? My idea is some sort of a base class that all my web controls could derive from, where I can handle the cascading of events perhaps with parameters that specify the parameters i want to pass, and which web control i want to take it to.
I just not sure how to go about it. Anyone have any experience with raising events in ASP.NET?
Cheers
This is a question on code design.
I have an application that uses the Box Model - as in that I have pages, and the pages are constructed by web controls all added within each other to get like a hierarchy of controls.
So for example, i may have a page that looks like this
page - webcontrol1 - webcontrol11 - webcontrol 111 - webcontrol 1111
- webcontrol 112
- webcontrol12 - webcontrol 121
- webcontrol2 - webcontrol21
like a treeview.
My question is that I've noticed that when I need one web control to speak to another, and they are on different parts of the page, i pretty much have to raise an event, and cascade it up all the parent web controls to the page level, then cascade it back up the webcontrols till i get to the destination web control.
Eg. if WebControl1111 needs to speak to WebControl21, I have to raise an event in 111, then 11, then 1, then the page, then 2, then 21
This creates a lot of repetive coding of event handling classes that pretty much just raise another event.
My question is, is there a better way to do this? My idea is some sort of a base class that all my web controls could derive from, where I can handle the cascading of events perhaps with parameters that specify the parameters i want to pass, and which web control i want to take it to.
I just not sure how to go about it. Anyone have any experience with raising events in ASP.NET?
Cheers