开发者

Inherit class from page, usercontrol, and masterpage

开发者 https://www.devze.com 2023-01-21 07:01 出处:网络
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

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

精彩评论

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

关注公众号