ControlAdapter.Control Właściwość

Definicja

Pobiera odwołanie do kontrolki, do której jest podłączona ta karta sterowania.

protected:
 property System::Web::UI::Control ^ Control { System::Web::UI::Control ^ get(); };
[System.ComponentModel.Browsable(false)]
protected System.Web.UI.Control Control { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Control : System.Web.UI.Control
Protected ReadOnly Property Control As Control

Wartość właściwości

Control

Element Control , do którego jest ControlAdapter dołączony.

Atrybuty

Przykłady

Poniższy przykład kodu pokazuje, jak uzyskać niestandardową kontrolkę z Control klasy, a następnie utworzyć odpowiednią kartę dziedziczą z ControlAdapter klasy. Adapter zastępuje Control właściwość i zwraca silnie typizowane odwołanie do kontrolki.

#using <System.Web.Mobile.dll>
#using <System.dll>
#using <System.Web.dll>

using namespace System;
using namespace System::Web::UI;
using namespace System::Web::UI::Adapters;
using namespace System::Web::UI::WebControls;

public ref class CustomControl: public Control{};

public ref class CustomControlAdapter: public ControlAdapter
{
public:

   property System::Web::UI::Control^ Control 
   {
      // Return a strongly-typed reference to your custom control.
      System::Web::UI::Control^ get()
      {
         return (CustomControl^)ControlAdapter::Control;
      }
   }
   // Override other ControlAdapter members, as necessary. 
};
using System;
using System.Web.UI;
using System.Web.UI.Adapters;
using System.Web.UI.WebControls;

public class CustomControl : Control
{
    // Add your custom control code.
}

public class CustomControlAdapter : ControlAdapter
{
    // Return a strongly-typed reference to your custom control.
    public new CustomControl Control
    {
        get
        {
            return (CustomControl)base.Control;
        }

        // Override other ControlAdapter members, as necessary. 
    }
}
Imports System.Web.UI
Imports System.Web.UI.Adapters
Imports System.Web.UI.WebControls

Public Class CustomControl
    Inherits Control

    ' Add your custom control code.

End Class

Public Class CustomControlAdapter
    Inherits ControlAdapter

    ' Return a strongly-typed reference to your custom control.
    Public Shadows ReadOnly Property Control() As CustomControl
        Get
            Return CType(MyBase.Control, CustomControl)
        End Get
    End Property

    ' Override other ControlAdapter member as necessary. 

End Class

Uwagi

Po dołączeniu pochodnej karty sterującej do kontrolki .NET Framework wywołuje niektóre elementy członkowskie karty zamiast elementów członkowskich kontrolki.

Uwagi dotyczące dziedziczenia

Gdy dziedziczysz z ControlAdapter klasy, co najmniej, należy zaimplementować Control właściwość, aby zwrócić silnie typizowane wystąpienie kontrolki, jak pokazano w sekcji Przykład.

Dotyczy

Zobacz też