Compile error when using "MasterType VirtualPath" directive

Last post 04-28-2009 5:18 PM by cooper88. 3 replies.

Sort Posts:

  • Compile error when using "MasterType VirtualPath" directive

    09-23-2008, 9:50 PM
    • Member
      point Member
    • nkk9960
    • Member since 09-24-2008, 1:30 AM
    • Posts 4

    I am in the process of converting a Web Site to a Web Application project.  The .aspx pages are all children of a master page, and they use the directive:

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

    From researching, I see everywhere that this is supposed to work.  But, in this case, the directive is causing a compile error:

    Error 1 Type 'WOPS_Solution.e332Master' is not defined. C:\Inetpub\wwwroot\WOPS_Solution\WOPS_Solution\AllOrders.aspx.designer.vb 402 50 WOPS_Solution

    in the child page designer files, on the WOPS_Solution.e332Master type:

    Public Shadows ReadOnly Property Master() As WOPS_Solution.e332Master
        Get
            Return CType(MyBase.Master, WOPS_Solution.e332Master)
        End Get
    End Property

    It will compile if I remove WOPS_Solution. , but I can't do that since it will re-generate next time the page is changed.  I created a new, quick and dirty, NOT CONVERTED, Web Application Project, with a master page and the directive, and a child page.  Of course, that works fine, so the problem must have something to do with the conversion. 

    Thanks in advance for any help in fixing this! 

     

     

  • Re: Compile error when using "MasterType VirtualPath" directive

    09-25-2008, 1:26 AM
    Answer

    Hi,

    In fact, the @MasterType directive provides a way to create a strongly typed reference to the ASP.NET master page when the master page is accessed from the Master property.

    So if you add the @ MasterType directive in the content page, you can write code in content pages that references properties, methods, and controls in the master page, with some restrictions. It is not necessary to declare master page in the content page.

    The more you can try to refert this MSDN article: http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Compile error when using "MasterType VirtualPath" directive

    01-15-2009, 4:39 PM
    • Member
      4 point Member
    • kagarrett
    • Member since 01-15-2009, 9:37 PM
    • Memphis, TN
    • Posts 2

     I'm having this exact problem.  My converted app has the problem, but a newly created test app does not.  Does anyone have a solution to this?

  • Re: Compile error when using "MasterType VirtualPath" directive

    04-28-2009, 5:18 PM
    • Member
      57 point Member
    • cooper88
    • Member since 04-13-2009, 4:49 AM
    • Posts 43

    I have the same problem. Very annoying. I think it is my web.config file. I remove it use a base copy it works. I edit the mastertype put it on top it works sometimes. I wish there was a solution also. Thought my code was broken for the entire afternoon when it was working.

Page 1 of 1 (4 items)