Eliyahu said:
<%@ MasterType virtualpath="~/myMasterPage.master" %>
will let you access all public members of the master as
this.Master.myMember
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
Managed Code said:
I have a BasePage class that derives from System.Web.UI.Page. All of my
content pages derive from this. The derived page classes use the
following MasterType declaration that follows to reference the master.
<%@ MasterType TypeName="MyMasterPage" %>
How do I reference the master page class from the BasePage?
Thanks...
mc
I tried the first option of
MyMasterPage masterPage = (MyMasterPage)this.Master;
which generated the following error
c:\inetpub\wwwroot\WorkFlow\App_Code\PageBase.cs(22,3): error CS0246:
The type or namespace name 'MyMasterPage' could not be found (are you
missing a using directive or an assembly reference?)
This cast works from a content page that derives directly from
System.Web.UI.Page and that has a corresponding aspx page, but does not
seem to work from the parent class that is inserted into the derivation
chain between the content page and System.Web.UI.Page;
As for the next option of
<%@ MasterType virtualpath="~/myMasterPage.master" %>
There is no corresponding content page for this parent class in which
to insert this directive.
Is there a content page derivation mechanism that will allow this?
Thanks,
mc