DataListDesigner Class
.NET Framework 2.0
Extends design-time behavior for the DataList Web server control.
Namespace: System.Web.UI.Design.WebControls
Assembly: System.Design (in system.design.dll)
System.Web.UI.Design.WebControls Namespace
DataList
DataListComponentEditor Class
Walkthrough: Creating a Basic Control Designer for a Web Server Control
Extending Design-Time Support
How to: Extend the Appearance and Behavior of Controls in Design Mode
Assembly: System.Design (in system.design.dll)
The following code example demonstrates how to extend the DataListDesigner class. The code overrides the GetDesignTimeHtml method to display a five-point border that is purple if the DataList control is enabled.
using System; using System.Drawing; using System.Security.Permissions; using System.ComponentModel; using System.Web.UI.WebControls; using System.Web.UI.Design; using System.Web.UI.Design.WebControls; ...namespace ASPNET.Examples.CS { [SecurityPermission( SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode)] public class SimpleGridViewDesigner : GridViewDesigner { private SimpleGridView simpleGView; public override string GetDesignTimeHtml() { string designTimeHtml = String.Empty; simpleGView = (SimpleGridView)Component; // Check the control's BorderStyle property to // conditionally render design-time HTML. if (simpleGView.BorderStyle == BorderStyle.NotSet) { // Save the current property settings in variables. int oldCellPadding = simpleGView.CellPadding; Unit oldBorderWidth = simpleGView.BorderWidth; Color oldBorderColor = simpleGView.BorderColor; // Set properties and generate the design-time HTML. try { simpleGView.Caption = "SimpleGridView"; simpleGView.CellPadding = 1; simpleGView.BorderWidth = Unit.Pixel(3); simpleGView.BorderColor = Color.Red; designTimeHtml = base.GetDesignTimeHtml(); } catch (Exception ex) { // Get HTML from the GetErrorDesignTimeHtml // method if an exception occurs. designTimeHtml = GetErrorDesignTimeHtml(ex); // Return the properties to their original values. } finally { simpleGView.CellPadding = oldCellPadding; simpleGView.BorderWidth = oldBorderWidth; simpleGView.BorderColor = oldBorderColor; } } else designTimeHtml = base.GetDesignTimeHtml(); return designTimeHtml; } protected override string GetErrorDesignTimeHtml(System.Exception exc) { return CreatePlaceHolderDesignTimeHtml( "ASPNET.Examples: An error occurred while rendering the GridView."); } public override void Initialize(IComponent component) { simpleGView = (SimpleGridView)component; base.Initialize(component); } } }
The following code example shows how to use the DesignerAttribute to associate the designer with the DataList control.
- SecurityPermission for calling unmanaged code. Demand value: Demand. Permission value: UnmanagedCode
Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Reference
DataListDesigner MembersSystem.Web.UI.Design.WebControls Namespace
DataList
DataListComponentEditor Class
Other Resources
ASP.NET Control Designers OverviewWalkthrough: Creating a Basic Control Designer for a Web Server Control
Extending Design-Time Support
How to: Extend the Appearance and Behavior of Controls in Design Mode
Show: