Solved

Call Method in ContentPlaceHolder Page's CodeBehind from MasterPage Method

Posted on 2009-04-13
3
1,508 Views
Last Modified: 2013-11-07
Hello,

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?

Thank You!
0
Comment
Question by:suchandsuch
  • 2
3 Comments
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 24130336
0
 
LVL 1

Author Comment

by:suchandsuch
ID: 24131406
Thanks raqi0017, you were right on about needing to implement an event and delegate in the masterpage (as well as needing to subscribe to that event in the contentplaceholder page).

I didn't find that link particularly useful, but that may be due to the fact that I haven't really coded my own delegates and events before.  Just in case someone else runs into this issue sometime, here's a link that I think is really helpful:

http://blogs.claritycon.com/blogs/steve_holstad/archive/2006/03/04/266.aspx

This isn't to diminish your contribution raqi0017, just to supplement it for users that are at a lower level (like myself).  Thanks again.
0
 
LVL 1

Author Closing Comment

by:suchandsuch
ID: 31569455
Thanks raqi0017, you were right on about needing to implement an event and delegate in the masterpage (as well as needing to subscribe to that event in the contentplaceholder page).

I didn't find that link particularly useful, but that may be due to the fact that I haven't really coded my own delegates and events before.  Just in case someone else runs into this issue sometime, here's a link that I think is really helpful:

http://blogs.claritycon.com/blogs/steve_holstad/archive/2006/03/04/266.aspx

This isn't to diminish your contribution raqi0017, just to supplement it for users that are at a lower level (like myself).  Thanks again.
0

Featured Post

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question