简体   繁体   中英

How do I inherit from an abstract UserControl?

If I have a class

abstract class DetailsForm : UserControl

then

AppDetailsForm : DetailsForm
BoxDetailsForm : DetailsForm

I can take advantage of inheritance to stick logic in DetailsForm.cs that applies to elements common among the tags in AppDetailsForm.aspx and BoxDetailsForm.aspx . These tags appear in both, in exactly the same place. There is duplicated header and footer code in AppDetailsForm.aspx and BoxDetailsForm.aspx that I'd rather stick in DetailsForm.cs .

The problem is I would need to stick a reference in DetailsForm.aspx that would refer to the content of the.aspx file in a child derived directly from that class.

However, currently, it only shows the content of AppDetailsForm.aspx or BoxDetailsForm.aspx , and ignores anything in DetailsForm.cs , so it seems like the reference to the other file should go AppDetailsForm.aspxDetailsForm.cs and BoxDetailsForm.aspxDetailsForm.cs .

I don't know how to do this, and I suspect I'm approaching this the wrong way.

I think Master pages are built for what you are trying to do.

Take a look at this link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM