0
我有包含嵌套服務器控件服務器控件,嵌套服務器控件
<uc1:ArticleControl runat="server">
<HeadLine></HeadLine>
<Blurb></Blurb>
<Body></Body>
</uc1:ArticleControl>
代碼:
[ToolboxData("<{0}:ArticleControl runat=server></{0}:ArticleControl>")]
[ParseChildren(ChildrenAsProperties = true)]
public class ArticleControl : WebControl
{
[PersistenceMode(PersistenceMode.InnerProperty)]
public HeadLineControl HeadLine
{
get;
set;
}
[PersistenceMode(PersistenceMode.InnerProperty)]
public BlurbControl Blurb
{
get;
set;
}
[PersistenceMode(PersistenceMode.InnerProperty)]
public BodyControl Body
{
get;
set;
}
}
嵌套控制定義(適用於所有嵌套控件):
public class HeadLineControl : ControlBase
{
public HeadLineControl() : base() { }
public HeadLineControl(Article article) : base(article) { }
基類定義
public abstract class ControlBase : Control
{
protected Article article;
protected ControlBase() { }
protected ControlBase(Article article)
{
this.article = article;
}
的ArticleControl負責編寫由嵌套控件所指定的商品的各個部分,
我的問題是,在創建Articlecontrol時,由.NET框架創建嵌套服務器控件的實例使用System.Web.UI.Control類如定義的默認構造函數:
namespace System.Web.UI
{
public class Control : IComponent, IDisposable, IParserAccessor, IUrlResolutionService, IDataBindingsAccessor, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor
{
// Summary:
// Initializes a new instance of the System.Web.UI.Control class.
public Control();
我需要調用或覆蓋的.Net的默認行爲,叫我Control基類的構造函數在默認的.NET代替定義構造器。簡而言之,如果創建了一個HeadLineControl的新實例,它需要由ControlBase(Article article)
構造函數創建。
這是可能的,如果可能的話,我該如何做到這一點?