473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Delegating Events between User Controls?

Hello community,

let's say I have a web form containing two User Controls, usrA and
usrB, respectively.

usrA.ascx has (among others) a Dropdown List ddL1 with
Autopostback=True and a ddL1_SelectedIndexChanged Handler.
usrB itsself has a child user control, usrBB.

I must delegate the ddL1_SelectedIndexChanged Event from usrA to
usrBB. How do I do that?

Is it really necessary to delegate (or bubble) the event from usrA to
the web form, then delgate the event from the web form to usrB, and
finally delegate the event from usrB to usrBB?

It seems that there is no way to 'reverse-bubble' the event from the
web form to usrBB or - better - to 'cross-bubble' the event from usrA
to usrBB.
In other words, there is no way for usrBB to access usrA (for event
registering) without extremly ugly casts.
Any ideas?
Best regards
Johannes
Nov 18 '05 #1
2 1323
> Is it really necessary to delegate (or bubble) the event from usrA to
the web form, then delgate the event from the web form to usrB, and
finally delegate the event from usrB to usrBB?


Yes! You break the Object-orientated approach to it if you do it any other way. (I'm not saying it can't be done, but I wouldn't do it) Create an event your usercontrol fires which you handle at your main page, and then push your way down to usrBB through usrB.

--Michael
Nov 18 '05 #2
Hello Michael,

first, thanks very much for your answer.
On Tue, 25 May 2004 16:04:52 -0400, "Raterus" <ra*****@spam.org>
wrote:
Is it really necessary to delegate (or bubble) the event from usrA to
the web form, then delgate the event from the web form to usrB, and
finally delegate the event from usrB to usrBB?


Yes! You break the Object-orientated approach to it if you do it any other way. (I'm not saying it can't be done, but I wouldn't do it) Create an event your usercontrol fires which you handle at your main page, and then push your way down to usrBB through usrB.

--Michael


The main problem is that there is no event broadcasting.

Another problem is exactly this 'push your way down to usrBB through
usrB'.

Version1:

usrBB's Event-Handler is public, usrBB is a public member of usrB,
usrB and usrA are members of webForm1.

webForm1 registers usrBB's Event-Handler something like:

this.usrA.UsrA_ListChanged += new
usrA.UsrA_ListChangedHandler(this.usrB.usrBB.UsrA_ ListChanged);

Version2:

I have to define a new event in webForm1. usrB has to register for
this event. I have to define another new event in usrB to have usrBB
registered. These new events are only for delegating the webForm1's
event (coming from the ddList in usrA) to usrBB.

Version3:

as described in

http://www.123aspx.com/redir.aspx?res=28491

Here the casts get very ugly although he 'only' has to transfer events
between User Controls directly under the main web form.

I have decided to use Version1, so I break encapsulation. Version2
just seems too cumbersome to me.

Now, suppose I hat to put another usrB1 in between usrB and usrBB.
Then I had to close the chain the hard way...

Best regards
Johannes



Well, in a way I have to break the Object-oriented approach, I have to
break encapsulation.

Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
1
by: Earl Teigrob | last post by:
PROBLEM: When a user control is loaded into a PlaceHolder control more than once, the events do not fire on the first click of a control on the dynamically loaded user control. In other words, the...
5
by: karthick raja | last post by:
Am experiencing a problem intercepting the events from controls added dynamically to a Placeholder control at runtime. Is there any way that I can write an event handler on the page which will be...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
4
by: thomson | last post by:
Hi all, i do have a user control with 4 buttons, and all the events are firing properly, My problem is that i need to right an event handler in the user control, which gets fired after a...
12
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown...
0
by: Scott McChesney | last post by:
I have a problem I hope you folks can help me with. I have an application that is using a tab-based interface, with the ability for users to drag an item from a ListBox onto the tab control. ...
5
by: snesbit | last post by:
If a screen is made up of several user controls and those user controls contain various packaged or standard controls such as a grid, how do you raise both standard and custom events from the user...
0
by: qreg | last post by:
I've got a problem with usercontrols and delegating events from the controls that are inside such a usercontrol control. First for a brief description of the problem. I have a user control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.