inheritance in ASP.NET

R

Ryan

Hi,

We use class extend parent class for cs file inheritance.
Is this same concept for page - mater page ?
And how we implement inheritance for user controls?

If I need add some common function, I can add it to base page class which
extends System.Web.UI.Page.

But if I want to add some common control on the page and functions deal with
those controls, I add both controls and functions to master page (or mater
of mater).

Is this right thoughts in ASP.NET?

I am never afraid to create too many base classes, but I don't know if it is
right thing to create a few master pages in one web application.

Thanks!
 
B

bruce barker

..net (unlike python and other languages) only supports single
inheritance. while it supports multiple interfaces, you can only define
the interface, not supply a default implementation.

so you can make a class that inherits from Page, add methods /
properties and have other pages inherit from your new page class, and
they all same the added methods/properties.

you can do the same for a masterpage, but you can not have your new
masterpage class inherit from your new page class. if you need to share
a method you will need to code it both (hopefully by calling a common
helper function defined in an unrelated class).

-- bruce (sqlwork.com)
 

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

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top