By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,275 Members | 936 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,275 IT Pros & Developers. It's quick & easy.

Cross user control communication via parent control

P: n/a
Here is the page architecture:
Page loads multiple user controls (including nested user controls)
dynamically based on parameters provided into place holders. Note: The
page only has the logic to load the user controls and subscribe to
custom event exposed in the user controls.

Scenario:
User comes to this page fills the fields generated by multiple user
controls and then hits "Save" button in one of the forms.

Question:
- How can all the information be collected in the control that has the
save button and saved to a repository?
- Is there a better practise?
- How can all the user controls be "wired" together to cross
communicate?

An example will be great help.

- Working with ASP.Net 2.0 using C#

Thanks in advance.

Jul 18 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
<ze***********@hotmail.comwrote in message
news:11*********************@z24g2000prh.googlegro ups.com...
Here is the page architecture:
Page loads multiple user controls (including nested user controls)
dynamically based on parameters provided into place holders. Note: The
page only has the logic to load the user controls and subscribe to
custom event exposed in the user controls.
Did you not see my reply to you? Here it is again:
-------------
"zb" <ze****@gmail.comwrote in message
news:11**********************@z24g2000prh.googlegr oups.com...
Here is the page architecture:
Page loads multiple user controls (including nested user controls)
dynamically based on parameters provided into place holders. Note: The
page only has the logic to load the user controls and subscribe to
custom event exposed in the user controls.

Scenario:
User comes to this page fills the fields generated by multiple user
controls and then hits "Save" button in one of the forms.

Question:
- How can all the information be collected in the control that has the
save button and saved to a repository?
- Is there a better practise?
- How can all the user controls be "wired" together to cross
communicate?
In the same way that you exposed the events from the user controls, you can
expose properties. Add properties to the user controls which will return the
data they have gathered from their input controls. The controlling page can
read those properties and use them to write to the repository.

I suggest that you do not do what is done by some code I know (you know who
you are!). Do not have a Save method on each user control, that accepts a
DataTable. The user control can fill the DataTable with the information it
has gathered.

The problem is that you have now closely tied each individual user control
to the structure of the data in your repository. It is better to separate
data from presentation. Instead, either have separate properties, or have a
property that returns a Data Transfer Object (DTO) from the user control. It
should return a struct containing all of the data collected by the user
control. Your calling page can take that data and put it into your
repository however it likes. The nice thing is that the user controls will
not need to change if the details of your data access layer change.
--
John Saunders [MVP]

Jul 19 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.