ASP.Net Inheritance

M

Mr Flibble

When you create your own class derived from System.Web.UI.Page and then
derive all your pages from this newly created class, can both the
"MyNewClass.aspx" and "MyNewClass.aspx.cs" be inherited or is it only
the code-behind that is inherited?
 
D

dkode

You only need to inherit from the code-behind which is where the page
declaration exists.

I am using this in a couple of my projects to provide static methods to
all pages.

public class BasePage : System.Web.UI.Page { }
 
P

PeterKellner

You only need to inherit from the code-behind which is where the page
declaration exists.

I am using this in a couple of my projects to provide static methods to
all pages.

public class BasePage : System.Web.UI.Page { }

You may be looking for usercontrols to get a similar feel to
inheritance fo the aspx file.
Peter Kellner
http://peterkellner.net
 
M

Mr Flibble

* Winista said:
Only the implementation code.

So I could just put common code in App_Code instead and this would offer
me the same functionality if I was only dealing with static methods. If
I want to modify certain behaviour of the page then it would make sense
to create my own subclass.
 
D

dkode

Mr said:
So I could just put common code in App_Code instead and this would offer
me the same functionality if I was only dealing with static methods. If
I want to modify certain behaviour of the page then it would make sense
to create my own subclass.

Actually, I correct myself, I was inheriting from a basepage to provide
access to session variables wrapped in properties to specific pages
that need to have access to the session variables, that way I didnt
have to create a static method that is only needed by a couple of
pages.

With the static methods, i did as you stated and made a class in
App_Code to provide static methods to my UI
 
D

dkode

PeterKellner said:
You may be looking for usercontrols to get a similar feel to
inheritance fo the aspx file.
Peter Kellner
http://peterkellner.net

I dont seem to follow your post Peter, were you responding to my
statement or the original posters?

p.s. I am using your membership editor on my webhost, very handy
feature seeing how microsoft never released a remote tool. thank you
for saving me hours of work!
 

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
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top