locked
Accessing properties from MasterPage RRS feed

  • Question

  • User-1308344544 posted

    I have an old ASP Web app that was successfully deployed to Azure.  In this application I am accessing property from master page in content page.

    Basically my master page has property 

    public string test { get; set; }

    Content aspx  has 

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

    and code behind

     if(Master.test == "dd")
                {

                }

    it works fine until I install Install-Package Microsoft.Graph 

    after that I am getting error

    'Site1' does not contain a definition for 'test' and no accessible extension method 'test' accepting a first argument of type 'Site1' could be found 

    I was playing with it a little and crated new project, installed Microsoft.Graph and created the same logic with Master\Content page as described above - and it  works..

    Any idea where to check?

    Friday, May 14, 2021 7:26 PM

Answers

  • User1686398519 posted

    Hi jstus, 

    jstus

    'Site1' does not contain a definition for 'test' and no accessible extension method 'test' accepting a first argument of type 'Site1' could be found 

    According to the error message, I suggest you to check if there is actually a test property in Site1.master.

        public partial class Site1 : System.Web.UI.MasterPage
        {
            public string test { get; set; }
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
        }

    Best Regards,

    YihuiSun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 17, 2021 7:19 AM