Sunday, March 11, 2012

Problem updating update panel on Master Page programatically

If you look in the source code of the master page MyMasterPage.Master.cs (or vb in your case) you'll see that all the controls on the page are protected; this is why you can't access the UpdatePanel. Allowing direct access to the UpdatePanel from any page it's a no-no from a design point of view. What I recommend is you make a public function in the code behind for the master page that calls the UpdatePanel's Update method; then call CType(Master, MyMaster).UpdateMyPanel(). If you really must give access to the UpdatePanel then you could create a public property that gives access to the UpdatePanel, something like (sorry, I'm rusty on VB syntax):

public UpdatePanel CoolUpdatePanel{get {return MyCoolUpdatePanel; }}

Thanks PBZ,

I didn't set it to Protected so I assume it is by default. Your solution sounds excellent though so I'll give it a try.


No comments:

Post a Comment