troubleshooting Question

ASP.NET FindControl on MasterPage

Avatar of Phil5780
Phil5780 asked on
5 Comments1 Solution385 ViewsLast Modified:
Hello All,

So I'm building a web page in ASP.NET/C# and have created a baseClass which implements login validation.  When my web page code behind is run its class inherits as follows:

public partial class ArchiveDash : LoginBaseClass

ArchiveDash is using a single master page with a control on it.  How do I access my master page control from my "LoginBaseClass"?  I tried to reach my controls like this but only received nulls:  (attached below)

//Intercept master page controls
        System.Web.UI.WebControls.HyperLink linkLocalLogIn = (System.Web.UI.WebControls.HyperLink)this.Page.FindControl("linkLogIn");
        System.Web.UI.WebControls.HyperLink linkLocalLogOut = (System.Web.UI.WebControls.HyperLink)this.Page.FindControl("linkLogOut");
        System.Web.UI.WebControls.Label lblLocalWelcomeUser = (System.Web.UI.WebControls.Label)this.Page.FindControl("lblWelcomeBackUser");

        //Toggle welcome banner
        if ((linkLocalLogIn != null) && (linkLocalLogOut != null))

Open in new window


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros