Call Method in ContentPlaceHolder Page's CodeBehind from MasterPage Method
Posted on 2009-04-13
I have a MasterPage that has a button click event handler in it (BtnLogin_Click) - this login control is wrapped in an updatepanel inside the MasterPage, so that when a user logs in, they see their login info replace the login controls in the MasterPage area.
What I'd like to do, is to be able to tell whatever page is loaded in the ContentPlaceHolder area of this MasterPage, that the user has logged in. Right now, only the items inside the MasterPage's UpdatePanel know that the user has logged in.
One way that I was thinking about would be to have a method in each page that uses this MasterPage, called UpdateItemsAffectedByLoginStatus (or something like that), so that when BtnLogin_Click in the MasterPage is executed, a line inside of BtnLogin_Click would call UpdateItemsAffectedByLoginStatus in the child or ContentPlaceHolder page's codebehind. This didn't get very far though, because while the child page can see the MasterPage's methods (if wired to do so), the Master, to my knowledge, can not access the child page's methods.
Is there a better way to achieve my goal (I'm sure there is) - or if not, can you help me to identify how to call a method in a ContentPlaceHolder page's CodeBehind, from a MasterPage's method or event handler?