Artin Falahi
Artin Falahi

Reputation: 1151

Inherit class from page, usercontrol, and masterpage

I have Page, MasterPage and UserControl in my project.

So I create basepage class and share some logic, then inherit from System.Web.UI.Page. My problem is I want use single basePage for any type of UI content.

Upvotes: 1

Views: 663

Answers (1)

Andrew Barber
Andrew Barber

Reputation: 40150

You can not inherit from multiple base classes in .NET, so you can not do what you are looking at here.

However, you probably do not need to do it. Page, MasterPage and UserControl can all access the currently rendering Page and MasterPage instances via properties. You can then test their actual types and cast them appropriately, to gain access to the common code you need.

Upvotes: 1

Related Questions