How do you drop from Page.Master to a specific master page in ASP.NET?

I have BasePageone that inherits from System.Web.UI.Page, and every page that inherits BasePagewill have the same main page.

How can I do Page.Masterfor a BasePagespecific main page so that I can access the properties on it?

+3
source share
3 answers

Override Master cannot be executed (its not Virtual) and masking it with new reasons causes the problem that the page class cannot get its master, therefore it is best to make the second property.

Sort of:

public CustomMasterPage MasterPage
{
    get { return this.Master as CustomMasterPage; }
}

In your BasePage class.

+3
source

MasterType , . .

<%@ MasterType VirtualPath="~/site.master" %>

:

this.Master.propertyName

.

+8

In VB.Net

MasterPageVariable = Ctype(page.MasterPage, MasterPageClass)
0
source

Source: https://habr.com/ru/post/1698229/


All Articles