Question

I have a situation where I need to update a control referenced in a masterpage from a control that is referenced from the content page. Below is hierarhcy:

  • MainMasterPage
    • BreadCrumbUserControl(a user control) - has a public string property
  • ContentPage(uses MainMasterPage)
    • DataUserControl

I want to be able to update the exposed property of BreadCrumbUserControl from DataUserControl on pageLoad.

I was able to update the BreadCrumbUserControl property just fine from the ContentPage. When i try to do the same DataUserControl's pageLoad method, the update is ignored because of page life cycle.

How can I go about achieving this? I can think of doing something on the clientside using hiddenField and such, but wanted to see if there is a better solution.

Thanks for your help.

Was it helpful?

Solution

It is possible to do what you are asking but I wouldn't. I would raise an event from the "DataUserControl" and handle it in the page. Then the page class can update the master page's control value. This will reduce coupling of your controls and the page they are used on.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top