I am trying to get a handle on a control (a contentPlaceHolder) on one of my master pages.
So I did a bit of research and foun out that you can't actually access it directly from a class in the app_code folder to them being compiled in different assemblies.
What I read is that you need to create a base class and derive that from the MasterPage class.
I'm not really sure how to do this???
If you look at the code below (which is in a class called ErrorHandler.cs in app_code) you will see a reference to Master. This is not allowed and throws an error saying I don't have access to it.
How do I get access to this master page via my class??
public void SetErrorContent(string contentPlaceHolderName, string controlName)
myContentPlaceHolder = (ContentPlaceHolder)Master.FindControl(contentPlaceHolderName);
if (myContentPlaceHolder != null)
myLabel = (Label)myContentPlaceHolder.FindControl(controlName);
if (myLabel != null)
myLabel.Text = "Label found!";