ListControlDesigner Class
Collapse the table of content
Expand the table of content

ListControlDesigner Class

Serves as the base class for designers that provide design-time support in the Visual Web Designer for controls that are derived from the ListControl abstract class.

Namespace:  System.Web.UI.Design.WebControls
Assembly:  System.Design (in System.Design.dll)

[SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)]
public class ListControlDesigner : DataBoundControlDesigner

In the Visual Web Designer, when the user switches from Source to Design view, the markup source code that describes a control derived from the ListControl class is parsed and a design-time version of the control is created on the design surface. When the user switches back to Source view, the design-time control is persisted to the markup source code and edited into the markup for the Web page. The ListControlDesigner class serves as the base class for designers that provide design-time support in the Visual Web Designer for controls that are derived from the ListControl.

The ListControlDesigner class properties provide the following functionality:

The ListControlDesigner class methods provide the following functionality:

This section provides two code examples. The first demonstrates how to derive a custom control designer. The second demonstrates how to associate a derived control with a designer.

The following code example shows how to create a class named SimpleRadioButtonListDesigner that inherits from the ListControlDesigner class. The SimpleRadioButtonListDesigner class overrides the GetDesignTimeHtml, Initialize, and OnDataSourceChanged methods. The SimpleRadioButtonListDesigner class displays a SimpleRadioButtonList control on the design surface.

using System;
using System.ComponentModel;
using System.Drawing;
using System.Diagnostics;
using System.Web.UI.WebControls;
using System.Web.UI.Design.WebControls;

namespace Examples.CS.WebControls.Design
    // Create the SimpleRadioButtonListDesigner, which provides 
    // design-time support for a custom list class. 
    public class SimpleRadioButtonListDesigner : ListControlDesigner
        SimpleRadioButtonList simpleRadioButtonList;
        bool changedDataSource;

        // Create the markup to display the control on the design surface.  
        public override string GetDesignTimeHtml()
            string designTimeMarkup = null;

            // Create variables to access the control 
            // item collection and back color.
            ListItemCollection items = simpleRadioButtonList.Items;
            Color oldBackColor = simpleRadioButtonList.BackColor;

            // Check the property values and render the markup 
            // on the design surface accordingly. 
                if (oldBackColor == Color.Empty)
                    simpleRadioButtonList.BackColor = Color.Gainsboro;

                if (changedDataSource)
                    items.Add("Updated to a new data source: " + 
                        DataSource + ".");

                // Call the base method to generate the markup.
                designTimeMarkup = base.GetDesignTimeHtml();
            catch (Exception ex)
                // Catch any exceptions that occur.
                designTimeMarkup = GetErrorDesignTimeHtml(ex);
                // Set the properties back to their original state.
                simpleRadioButtonList.BackColor = oldBackColor;

            return designTimeMarkup;
        } // GetDesignTimeHtml 

        public override void Initialize(IComponent component)
            // Ensure that only a SimpleRadioButtonList can be  
            // created in this designer.
                component is SimpleRadioButtonList, 
                "An invalid SimpleRadioButtonList control was initialized.");

            simpleRadioButtonList = (SimpleRadioButtonList)component;
        } // Initialize 

        // If the data source changes, set a boolean variable. 
        public override void OnDataSourceChanged()
            changedDataSource = true;
        } // OnDataSourceChanged
    } // SimpleRadioButtonListDesigner
} // Examples.CS.WebControls.Design

The following code example derives the SimpleRadioButtonList control from the RadioButtonList control, and shows how to use the DesignerAttribute class to associate the SimpleRadioButtonList control with its designer, the SimpleRadioButtonListDesigner class.

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Security.Permissions;

namespace Examples.CS.WebControls.Design
    // The SimpleRadioButtonList is a copy of the RadioButtonList. 
    // It uses the SimpleRadioButtonListDesigner for design-time support.
        Level = AspNetHostingPermissionLevel.Minimal)]
        Level = AspNetHostingPermissionLevel.Minimal)]
    public class SimpleRadioButtonList : RadioButtonList
    } // SimpleRadioButtonList
} // Examples.CS.WebControls.Design

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

Community Additions

© 2016 Microsoft