ControlBuilder.AppendSubBuilder(ControlBuilder) Method

Definition

針對屬於容器控制項的任何子控制項,將產生器加入 ControlBuilder 物件中。Adds builders to the ControlBuilder object for any child controls that belong to the container control.

public:
 virtual void AppendSubBuilder(System::Web::UI::ControlBuilder ^ subBuilder);
public virtual void AppendSubBuilder (System.Web.UI.ControlBuilder subBuilder);
abstract member AppendSubBuilder : System.Web.UI.ControlBuilder -> unit
override this.AppendSubBuilder : System.Web.UI.ControlBuilder -> unit
Public Overridable Sub AppendSubBuilder (subBuilder As ControlBuilder)

Parameters

subBuilder
ControlBuilder

指派給子控制項的 ControlBuilder 物件。The ControlBuilder object assigned to the child control.

Examples

下列範例會覆寫 AppendSubBuilder 方法,以擲回 Exception (如果套用此控制項產生器的控制項嘗試在其 ControlCollection 類別的實例中包含控制項)。The following example overrides the AppendSubBuilder method to throw an Exception if the control this control builder is applied to tries to include controls in its instance of ControlCollection class.

// Override the AppendSubBuilder method to throw an
// exception if the class it is applied to attempts
// to include child controls. 
public override void AppendSubBuilder(ControlBuilder subBuilder)
{
    throw new Exception(
        "A custom label control cannot contain other objects.");
}
' Override the AppendSubBuilder method to throw an
' exception if the class it is applied to attempts
' to include child controls. 
Public Overrides Sub AppendSubBuilder(ByVal subBuilder As ControlBuilder)
    Throw New Exception( _
       "A custom label control cannot contain other objects.")
End Sub

Applies to

See also