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

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top