Access MasterPage variable on content page

I am trying to reference a variable in my MasterPage, but I am getting errors.

I tried

<%@ MasterType" %>

which gives the following error:

Compiler Error Message: CS0030: Unable to Convert Type 'IPAMIntranet.IPAMIntranetMaster' to 'ASP.ipamintranetmaster_master'

and

string tVar = ((MyNamespace.MyMasterPage)Master).variable 

which gives the following error:

Cannot start object of type 'ASP.ipamintranetmaster_master' for type 'IPAMIntranet.IPAMIntranetMaster'.

Does anyone know what is going on, or am I missing something.

0
source share
3 answers

I dealt with this using the interface.

0
source

You need to specify the virtual path to the main page on the content page.

<%@ MasterType VirtualPath="Master.Master" %>
0

, IPAMIntranet.IPAMIntranetMaster, IPAMIntranet.IPAMIntranetMaster, - , .

MasterType , , intellisense. VirtualPath , TypeName, , , , .

0

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


All Articles