:)
Well, I'm actually going to be working on an article over the next two weeks that should touch on this subject.
What if you had your master page(s) inherit from a base class in App_Code. It would look something like the following (I'm going to demonstrate with a Label control, because I don't have a tabbed navigation thingy :)). The concept works the same - you'll just need to add properties for your special navigation controls.
Anyway - let's say I have the following in App_Code:
public class MasterBase : MasterPage
{
// make sure your control field is marked as protected, not private.
protected Label _footer;
public Label FooterLabel
{
get { return _footer; }
set { _footer = value; }
}
}
My master page would look something like:
<%@ Master ... Inherits="MasterPage" CodeFileBaseClass="MasterBase" %>
...
<asp:Label ID="_footer" runat="server" />
Make sure to set the CodeFileBaseClass so the runtime can wire up the _footer control in the markup with the protected _footer control in your base class. The code-beside for the master page just needs to derive from the MasterBase
public partial class MasterPage : MasterBase
{
// ...
}
Now, if I have a PageBase class in App_Code, it can see the MasterBase Type, and it can cast it's Master property to that type and fiddle with any of the properties defined on MasterBase.
public class PageBase : Page
{
protected void DoSomethingWithLabel()
{
MasterBase master = Master as MasterBase;
master.FooterLabel.Text = "Hello, I am a label";
}
}
So now I'm changing the properties of my master pages from a base class in App_Code. Basically I'd have the controls as properties on my base master page class.
Is that helpful at all?