inheritance in ASP.NET

  • Thread starter Thread starter Ryan
  • Start date Start date
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!
 
..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)
 
Back
Top