asp.net 2.0 creating a base page

P

Pini

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

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
 
P

Pini

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 כתב:
 
S

S. Justin Gengo

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


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 ???:
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top