MasterType Problem

Last post 06-03-2008 2:47 AM by z0333. 4 replies.

Sort Posts:

  • MasterType Problem

    05-28-2008, 3:18 AM
    • Member
      52 point Member
    • z0333
    • Member since 04-29-2007, 3:53 AM
    • Posts 83

     

    Hi,

    I've followed this link http://forums.asp.net/p/980694/1266579.aspx#1266579 while trying to access my master page public properties.

    My master page is located on the web site root. I'm using a web site solution (not a web app).

    I've created a class driven from System.Web.UI.Page on the App_Code folder:

     

    Imports Microsoft.VisualBasic

     

    Public Class myPage

        Inherits System.Web.UI.Page

     

        Public Shadows ReadOnly Property Master() As myMaster

            Get

                Return CType(MyBase.Master, myMaster)

            End Get

        End Property

     

    End Class

     

    I'm getting an error "type 'myMaster' is not defined" (I get the same error if I try to use ASP. myMaster)

     

    I guess that if I'll place the master page on the App_Code folder every thing will be fine, but I don't like this approach.

     

    Is there's a way around?

     

    Thanks

    Z.

     

     

  • Re: MasterType Problem

    05-28-2008, 7:46 AM
    • Contributor
      5,243 point Contributor
    • DarthSwian
    • Member since 12-04-2007, 7:47 PM
    • Florida
    • Posts 1,020

     I'm not sure what you're trying to do but you don't place the master page in the app_code directory, bad idea.

    "Hokey religions and ancient weapons are no match for a good blaster at your side."
  • Re: MasterType Problem

    05-28-2008, 8:19 AM
    • Member
      52 point Member
    • z0333
    • Member since 04-29-2007, 3:53 AM
    • Posts 83

     

    As in the link above, I want to create a new base class for my pages, driven from the page class. By shadowing the Master property I won't have to place the <%@ MasterType TypeName="MYMaster.MasterPage" %> tag on each page.

    Placing the master page in the App_Code folder is not an option...

  • Re: MasterType Problem

    05-30-2008, 2:18 AM

    Hi,

    Using the @ MasterType directive in the ASPX which is a strongly typed Master Page. You don’t need a cast, we can go right to access the Master property.

    If you don't want to add @MasterType directive for each content page, you need to use a cast to get the MasterPage reference and access the master page for a web form using the inherited Master property.

    Try to check this link: http://odetocode.com/Blogs/scott/archive/2005/07/16/1944.aspx

    hope it helps.

    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: MasterType Problem

    06-03-2008, 2:47 AM
    • Member
      52 point Member
    • z0333
    • Member since 04-29-2007, 3:53 AM
    • Posts 83

    I'll be more spesific... that's my problem:

     

    z0333:

    I'm getting an error "type 'myMaster' is not defined" (I get the same error if I try to use ASP. myMaster)

Page 1 of 1 (5 items)