Sending custom events between page controls

J

John Wallace

Hi,

I have a webform with two entirely different kinds of user control,
called for example "source" and "target". Is it possible for one
"source" to raise events to which one or more "target" controls will
respond (if any "target" controls exists on the page)?

Basically I want "source" to shout out messages that any listening
"target" controls on the page will respond to.

The event docs I've looked at focus on "bubbling" and the event
hierarchy, etc. "Source" and "target" are not composited or really
related in any way (other than the events) so my scenario is more like
"control cooperation" than "hierarchy".

Thanks,
John
 
T

Teemu Keiski

Yes it is. The important is just that "target" control can wire an event
handler for "source"'s event and that means it needs to access the "source"
user control instance somehow. You could for example in Page_Load in the
"target" use Page.FindControls to locate the "source" control and then wire
the event handler.

--
Teemu Keiski
MCP,Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top