次の方法で共有


ControlCollection.Owner プロパティ

ControlCollection オブジェクトが属する ASP.NET サーバー コントロールを取得します。

名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)

構文

'宣言
Protected ReadOnly Property Owner As Control
'使用
Dim value As Control

value = Me.Owner
protected Control Owner { get; }
protected:
property Control^ Owner {
    Control^ get ();
}
/** @property */
protected Control get_Owner ()
protected function get Owner () : Control
適用できません。

プロパティ値

ControlCollection が属する Control

使用例

次に示すのは、ControlCollection クラスの ControlCollection メソッドをオーバーライドするカスタム クラスのコード例です。このカスタム クラスでは、コレクションのインスタンスが作成されるとトレース ログにメッセージ (Owner プロパティの名前を含む) が書き込まれます。この例を使用するには、ページまたはアプリケーションでトレースの機能が有効になっている必要があります。

' Create a custom ControlCollection that writes
' information to the Trace log when an instance
' of the collection is created.
<AspNetHostingPermission(SecurityAction.Demand, _
   Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class CustomControlCollection
    Inherits ControlCollection

    Private context As HttpContext

    Public Sub New(ByVal owner As Control)
        MyBase.New(owner)
        HttpContext.Current.Trace.Write("The control collection is created.")
        ' Display the Name of the control
        ' that uses this collection when tracing is enabled.
        HttpContext.Current.Trace.Write("The owner is: " _
      & Me.Owner.ToString())
    End Sub


End Class
// Create a custom ControlCollection that writes
// information to the Trace log when an instance
// of the collection is created.
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public class CustomControlCollection : ControlCollection
{
    private HttpContext context;

    public CustomControlCollection(Control owner)
        : base(owner)
    {

        HttpContext.Current.Trace.Write("The control collection is created.");
        // Display the Name of the control
        // that uses this collection when tracing is enabled.
        HttpContext.Current.Trace.Write("The owner is: " + this.Owner.ToString());
    }
}

プラットフォーム

Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition

Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。

バージョン情報

.NET Framework

サポート対象 : 3.0,2.0,1.1,1.0

参照

関連項目

ControlCollection クラス
ControlCollection メンバ
System.Web.UI 名前空間
Control.Controls プロパティ