This documentation is archived and is not being maintained.

DataListDesigner Class

Extends design-time behavior for the DataList Web server control.

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

<SupportsPreviewControlAttribute(True)> _
<SecurityPermissionAttribute(SecurityAction.Demand, Flags := SecurityPermissionFlag.UnmanagedCode)> _
Public Class DataListDesigner _
	Inherits BaseDataListDesigner
Dim instance As DataListDesigner

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.

Imports System
Imports System.Drawing
Imports System.ComponentModel
Imports System.Web.UI.WebControls
Imports System.Security
Imports System.Web.UI.Design
Imports System.Web.UI.Design.WebControls
Imports Microsoft.VisualBasic

Namespace ASPNET.Examples
    < _
        Designer("ASPNET.Examples.Design.SimpleGridViewDesigner", _
            "System.Web.UI.Design.GridViewDesigner") _
    > _
    Public Class SimpleGridView
        Inherits GridView

        ' Code to customize your GridView goes here

    End Class
End Namespace

Namespace ASPNET.Examples.Design
    <Permissions.SecurityPermission( _
    Permissions.SecurityAction.Demand, _
    Flags:=Permissions.SecurityPermissionFlag.UnmanagedCode)> _
    Public Class SimpleGridViewDesigner
        Inherits GridViewDesigner

        Private simpleGView As SimpleGridView

        Public Overrides Function GetDesignTimeHtml() As String
            Dim designTimeHtml As String = String.Empty

            simpleGView = CType(Component, SimpleGridView)

            ' Check the control's BorderStyle property to  
            ' conditionally render design-time HTML.
            If (simpleGView.BorderStyle = BorderStyle.NotSet) Then
                ' Save the current property settings in variables.
                Dim oldCellPadding As Integer = simpleGView.CellPadding
                Dim oldBorderWidth As Unit = simpleGView.BorderWidth
                Dim oldBorderColor As Color = simpleGView.BorderColor

                ' Set properties and generate the design-time HTML.
                    simpleGView.Caption = "SimpleGridView"
                    simpleGView.CellPadding = 1
                    simpleGView.BorderWidth = Unit.Pixel(3)
                    simpleGView.BorderColor = Color.Red

                    designTimeHtml = MyBase.GetDesignTimeHtml()

                Catch ex As Exception
                    ' Get HTML from the GetErrorDesignTimeHtml 
                    ' method if an exception occurs.
                    designTimeHtml = GetErrorDesignTimeHtml(ex)

                    ' Return the properties to their original values.
                    simpleGView.CellPadding = oldCellPadding
                    simpleGView.BorderWidth = oldBorderWidth
                    simpleGView.BorderColor = oldBorderColor
                End Try

                designTimeHtml = MyBase.GetDesignTimeHtml()
            End If

            Return designTimeHtml
        End Function

        Protected Overrides Function _
            GetErrorDesignTimeHtml(ByVal exc As Exception) As String

            Return CreatePlaceHolderDesignTimeHtml( _
                "ASPNET.Examples: An error occurred while rendering the GridView.")

        End Function

        Public Overrides Sub Initialize(ByVal component As IComponent)

            simpleGView = CType(component, SimpleGridView)


        End Sub
    End Class
End Namespace

The following code example shows how to use the DesignerAttribute to associate the designer with the DataList control.

< _
    Designer("ASPNET.Examples.Design.SimpleGridViewDesigner", _
        "System.Web.UI.Design.GridViewDesigner") _
> _
Public Class SimpleGridView
    Inherits GridView

    ' Code to customize your GridView goes here 

End Class

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