开发者

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜