Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
In general I would like to know from anybody how you can let two usercontrols on the same page communicate with each other. I have seen so many examples and solutions, but none of them let my two usercontrols be aware of the fact that the other one had a request or information for the other one.
In short: in the first usercontrol the user fills in a textbox and submits this information with a button to the database. At the same time the other usercontrol should respond to this action and show the - let's say - new total of this particular item in the database automatically. How can I trigger the seond usercontrol to do this?!?
Should you use the masterpage? If it doesn't have a code-behind, should you create that? Why doesn't Page.FindControl(...) which seems to be the key to the solution work as promised anyware?
It can be done by clicking the submit button twice, but that is something you cannot ask a user to do!
Thanks in advance!
By the way: we use Windows Server 2008, IIS 7, ASP.NET 3.5 and the latest Umbraco version
I believe you should be able to look through the Page's controls that the control belongs to. If you find the type of control you are looking for, you can typecast that control to your control type and use it.
I think you have 2 options:
1. Use events. You can raise an event each time a record is updated and the "Calculate Total Usercontrol" can act on that and calculate and display the new total,but you still have an issue subscribe to these events.
2. In the "Calculate Total" usercontrol don't display the total on the Load Event but use the PreRender event. The button Click event that is raised when the user submits the data is fired after the Load event and that's why you don't see the results yet. On my weblog you'll find a poster about the Page Lifecycle (intro is in Dutch but I'm sure you can read that :P)
Richards options sound ideal.
Try and think about it differently. You don't want your controls to communicate with each other, you want one control to update the state (maybe session variable?) and the second control to respond to this change.
Jonathan, Richard and Chris!
I thank you all for responding to my cry for help. But in particular I have to thank you, Richard, for your 'pre_render' suggestion.
'What's in a name!?' As soon as I changed my 'Page_Load' into 'Page_PreRender' things started working as I had planned.
Not that I have seen the light, but that is not my concern, right now. I have seen a lot and I have learned some things over the past few days, but I am happy that my Synergy4U partner forced me to make my development problems known on the Umbraco forum.
Thanks again and hopefully (not?) till next time!
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted