[英]How do I inherit from an abstract UserControl?
If I have a class如果我有 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
.我可以利用 inheritance 将逻辑粘贴到DetailsForm.cs
中,该逻辑适用于AppDetailsForm.aspx
和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
. AppDetailsForm.aspx
和BoxDetailsForm.aspx
中有重复的 header 和页脚代码,我宁愿坚持在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.问题是我需要在DetailsForm.aspx
中添加一个引用,该引用将引用直接从该 class 派生的子项中的 .aspx 文件的内容。
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.aspx
→ DetailsForm.cs
and BoxDetailsForm.aspx
→ DetailsForm.cs
.但是,目前它只显示AppDetailsForm.aspx
或BoxDetailsForm.aspx
的内容,并忽略DetailsForm.cs
中的任何内容,因此似乎对其他文件的引用应该 go AppDetailsForm.aspx
→ DetailsForm.cs
和BoxDetailsForm.aspx
→ DetailsForm.cs
。
I don't know how to do this, and I suspect I'm approaching this the wrong way.我不知道该怎么做,而且我怀疑我以错误的方式处理这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.