asp.net 2.0 creating a base page

Discussion in 'ASP .Net' started by Pini, Sep 12, 2006.

  1. Pini

    Pini Guest

    Hi all,In asp.net 1.x i creates a basepage that extends
    System.Web.UI.Page class.
    I created this file in a web appplcaition project and then refernced it
    from another projects.
    All the pages in this project inherited from this new BasePage ionstead
    of the Page class.

    In asp.net 2.0 i dont seem to make this work.
    I did the same thing. precompile the project and then added refernce to
    the assemblies in the precompiled directory.

    It doesnt seem to work since i put a break point at the Page_Load event
    and others in the base class and it doesnt seem to reach there.

    What shoul i do?

    by the way if i put the basepage in the App_Code direcotry - it doent
    evenrecognice this base class.(No namespace problem)

    anyone?
     
    Pini, Sep 12, 2006
    #1
    1. Advertising

  2. Pini,

    In .NET 2.0 there is an easier way to get the same functionality. You can
    create a master page. Then use that master page for each new page. In the
    new page's html code view you can then add a Master Type directive which
    will then let you use any code from the master page.

    Here's a how-to:
    http://odetocode.com/Blogs/scott/archive/2005/07/16/1944.aspx

    Regards,

    --
    S. Justin Gengo
    Web Developer / Programmer

    Free code library:
    http://www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche


    "Pini" <> wrote in message
    news:...
    > Hi all,In asp.net 1.x i creates a basepage that extends
    > System.Web.UI.Page class.
    > I created this file in a web appplcaition project and then refernced it
    > from another projects.
    > All the pages in this project inherited from this new BasePage ionstead
    > of the Page class.
    >
    > In asp.net 2.0 i dont seem to make this work.
    > I did the same thing. precompile the project and then added refernce to
    > the assemblies in the precompiled directory.
    >
    > It doesnt seem to work since i put a break point at the Page_Load event
    > and others in the base class and it doesnt seem to reach there.
    >
    > What shoul i do?
    >
    > by the way if i put the basepage in the App_Code direcotry - it doent
    > evenrecognice this base class.(No namespace problem)
    >
    > anyone?
    >
     
    S. Justin Gengo, Sep 12, 2006
    #2
    1. Advertising

  3. Pini

    Pini Guest

    Hi there Justin and thanks for your reply.
    First of all i do know about master pages, bus i dont think they are a
    subtitued for Page inheritance.All they do is provide a template and
    the same look and feel in all of the pages, please correct me if i am
    wrong.

    I want to find a way to give all my pages some functionality and not
    just the same look and feel.

    Is there a way to do this in asp.net.2.0 ?

    Do you mean master pages replaces the inheritance "trick"?





    S. Justin Gengo כתב:
    > Pini,
    >
    > In .NET 2.0 there is an easier way to get the same functionality. You can
    > create a master page. Then use that master page for each new page. In the
    > new page's html code view you can then add a Master Type directive which
    > will then let you use any code from the master page.
    >
    > Here's a how-to:
    > http://odetocode.com/Blogs/scott/archive/2005/07/16/1944.aspx
    >
    > Regards,
    >
    > --
    > S. Justin Gengo
    > Web Developer / Programmer
    >
    > Free code library:
    > http://www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzsche
    >
    >
    > "Pini" <> wrote in message
    > news:...
    > > Hi all,In asp.net 1.x i creates a basepage that extends
    > > System.Web.UI.Page class.
    > > I created this file in a web appplcaition project and then refernced it
    > > from another projects.
    > > All the pages in this project inherited from this new BasePage ionstead
    > > of the Page class.
    > >
    > > In asp.net 2.0 i dont seem to make this work.
    > > I did the same thing. precompile the project and then added refernce to
    > > the assemblies in the precompiled directory.
    > >
    > > It doesnt seem to work since i put a break point at the Page_Load event
    > > and others in the base class and it doesnt seem to reach there.
    > >
    > > What shoul i do?
    > >
    > > by the way if i put the basepage in the App_Code direcotry - it doent
    > > evenrecognice this base class.(No namespace problem)
    > >
    > > anyone?
    > >
     
    Pini, Sep 13, 2006
    #3
  4. Pini,

    Yes, master pages can be used the way you want. No, I don't think they are a
    complete substitute for page inheritance, but they get very very close.

    If you put this line in the source code view of the .aspx template file:

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

    You will then have access to any method you've placed into the master page's
    code behind. For example if you place a subroutine for logging exceptions
    that takes a string description and the exception itself as parameters on
    your master page, you could then call it from your template like this:

    Call Master.ProcessException("There was an error on page load:", ex)

    Thus giving you the same access to common functionality that page
    inheritance would have given you.

    Regards,

    --
    S. Justin Gengo
    Web Developer / Programmer

    Free code library:
    http://www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche


    "Pini" <> wrote in message
    news:...
    Hi there Justin and thanks for your reply.
    First of all i do know about master pages, bus i dont think they are a
    subtitued for Page inheritance.All they do is provide a template and
    the same look and feel in all of the pages, please correct me if i am
    wrong.

    I want to find a way to give all my pages some functionality and not
    just the same look and feel.

    Is there a way to do this in asp.net.2.0 ?

    Do you mean master pages replaces the inheritance "trick"?





    S. Justin Gengo ???:
    > Pini,
    >
    > In .NET 2.0 there is an easier way to get the same functionality. You can
    > create a master page. Then use that master page for each new page. In the
    > new page's html code view you can then add a Master Type directive which
    > will then let you use any code from the master page.
    >
    > Here's a how-to:
    > http://odetocode.com/Blogs/scott/archive/2005/07/16/1944.aspx
    >
    > Regards,
    >
    > --
    > S. Justin Gengo
    > Web Developer / Programmer
    >
    > Free code library:
    > http://www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzsche
    >
    >
    > "Pini" <> wrote in message
    > news:...
    > > Hi all,In asp.net 1.x i creates a basepage that extends
    > > System.Web.UI.Page class.
    > > I created this file in a web appplcaition project and then refernced it
    > > from another projects.
    > > All the pages in this project inherited from this new BasePage ionstead
    > > of the Page class.
    > >
    > > In asp.net 2.0 i dont seem to make this work.
    > > I did the same thing. precompile the project and then added refernce to
    > > the assemblies in the precompiled directory.
    > >
    > > It doesnt seem to work since i put a break point at the Page_Load event
    > > and others in the base class and it doesnt seem to reach there.
    > >
    > > What shoul i do?
    > >
    > > by the way if i put the basepage in the App_Code direcotry - it doent
    > > evenrecognice this base class.(No namespace problem)
    > >
    > > anyone?
    > >
     
    S. Justin Gengo, Sep 15, 2006
    #4
    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. Vadim Vulfov

    Creating multi-page dynamic page in ASP.NET

    Vadim Vulfov, Jun 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    660
    Vadim Vulfov
    Jun 2, 2005
  2. Replies:
    0
    Views:
    973
  3. =?Utf-8?B?YmFseXN0eWs=?=
    Replies:
    1
    Views:
    5,701
    Karl Seguin
    Dec 31, 2005
  4. tomek
    Replies:
    2
    Views:
    685
    Andrey Tarasevich
    Dec 1, 2003
  5. Stephane
    Replies:
    0
    Views:
    1,797
    Stephane
    Jan 30, 2009
Loading...

Share This Page