Archive for July, 2007

Updating a control in a MasterPage from a UserControl

Thursday, July 5th, 2007

Problem: You have a control, for example a Label, in a MasterPage that you want to update from a UserControl added to a page that resides in the MasterPage’s ContentPlaceHolder control (see figure 1).

Figure 1: From MasterPage to UserControl

I was facing this problem a few months back on a project, where I had many different UserControls that was added to a limited number of pages, and all the pages had the same master page. I wanted an elegant way of updating the status label in my MasterPage while limiting the amount of redundant code. After googling around a bit, I ended up combining a few different solutions into the following.

(more…)