ControlAdapter.Control Property

Definition

Gets a reference to the control to which this control adapter is attached.

C#
[System.ComponentModel.Browsable(false)]
protected System.Web.UI.Control Control { get; }

Property Value

The Control to which this ControlAdapter is attached.

Attributes

Examples

The following code example shows how to derive a custom control from the Control class, and then create a corresponding adapter that inherits from the ControlAdapter class. The adapter overrides the Control property and returns a strongly-typed reference to the control.

C#
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. 
    }
}

Remarks

When a derived control adapter is attached to a control, the .NET Framework calls certain adapter members instead of the control members.

Notes to Inheritors

When you inherit from the ControlAdapter class, at a minimum, you should implement a Control property to return a strongly-typed instance of the control, as shown in the Example section.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also