understanding master pages

Discussion in 'ASP .Net' started by Diego, Apr 1, 2005.

  1. Diego

    Diego Guest

    Hi all
    I'd like to understand something about master pages:
    1)Why if if try to typecast a masterpage inside a "child page" the compiler
    tells it dont find the class? I was trying to declare a property in the
    master and access it from the child but the problem is not with the
    property, is with the typecast of the class
    2)Why both master page and child pages are declared as partial class?
    3)Why the events in the Master pages are "created" by Visual Web Developer
    2005 EE in the aspx page and not in the codebehind one?
    Thanks, Diego
     
    Diego, Apr 1, 2005
    #1
    1. Advertising

  2. Diego

    Brock Allen Guest

    The Master and Page get merged together in terms of their control hierarchys
    but they're not related via inheritance. But you can have one access the
    other as objects. In the child ASPX you want to add the directive:

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

    The in your ASPX just use Page.Master.SomePublicProp to access the data form
    the master.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hi all
    > I'd like to understand something about master pages:
    > 1)Why if if try to typecast a masterpage inside a "child page" the
    > compiler
    > tells it dont find the class? I was trying to declare a property in
    > the
    > master and access it from the child but the problem is not with the
    > property, is with the typecast of the class
    > 2)Why both master page and child pages are declared as partial class?
    > 3)Why the events in the Master pages are "created" by Visual Web
    > Developer
    > 2005 EE in the aspx page and not in the codebehind one?
    > Thanks, Diego
     
    Brock Allen, Apr 1, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Electrified Research
    Replies:
    5
    Views:
    2,471
    =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN
    Oct 11, 2005
  2. Doug McCann
    Replies:
    1
    Views:
    1,065
    William Brogden
    Aug 5, 2004
  3. Replies:
    1
    Views:
    3,239
    PeterKellner
    May 16, 2006
  4. Sam
    Replies:
    0
    Views:
    710
  5. Sam
    Replies:
    1
    Views:
    787
Loading...

Share This Page