Help: Getting two controls to talk etc.

S

Scamps

I'm struggling real bad.
I have created a WUC with a calandar object in it (Cal.ascx).
I have a second WUC with a DataGrid in it (Events.ascx).
I want to select a date in the Calendar WUC, and use the selection event to
pass the date as a parameter to the WUC containing the datagrid and bind the
resultant data set to the grid and display it
Both WUCs are programatically added to the DeskTopDefault.aspx page.
I just cant find out how to do it. Non of the books I have read even hint at
doing this, yet it seems such a basic concept?? Helppppppp.
 
B

Brock Allen

You need to make a public property on one that the page can call to get the
date, then make another method/property on the other that the page can set.
The page needs to coordinate the two, as in general, controls are built to
not know about other controls on the page.
 
M

Matt

How does the reader of the property know that the property was already
set ... or that it won't change just after the read? I guess that's
where the page comes in coordinating the communication, but wouldn't
this be better with the settor firing events and the reader subscribing
to those events ... In this case the page wouldn't need to coordinate
anything, right?
 
B

Brock Allen

How does the reader of the property know that the property was already
set ... or that it won't change just after the read? I guess that's
where the page comes in coordinating the communication, but wouldn't
this be better with the settor firing events and the reader
subscribing to those events ... In this case the page wouldn't need to
coordinate anything, right?

Oh yeah,. of course. If the first UC allows the user to set the date, then
of course the best way for it to notify someone is via an event that the
page should handle and then ferry the value over to the other UC. That's
a good and important addition to the prior suggestion. But I still think
when !IsPostBack the page is probabaly going to have do the initial coordination.
 
S

Scamps

Ok. I can understand the concept of having the page act as the "communicator"
but in practice I cant get this to work. Can any of you point me in the
direction of a good working example that is also well documented. If I can
get an example up and running, I can figure out how it works.
 
S

Scamps

Brock, Thanks for the link. I have made very good progress in learning the
solution. The answer lies in 'Events and Delegates'. I've created a working
model from an article I got from MSDN and now I'm applying it to my project.
touch wood, I'm almost there!
 

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,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top