This documentation is archived and is not being maintained.

HierarchicalDataBoundControlDesigner Class

Provides design-time support in a designer host for the HierarchicalDataBoundControl control.

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

'Declaration
Public Class HierarchicalDataBoundControlDesigner _
	Inherits BaseDataBoundControlDesigner
'Usage
Dim instance As HierarchicalDataBoundControlDesigner

In a designer host, when the user switches from Source to Design view, the markup source code that describes a control that is derived from the HierarchicalDataBoundControl abstract 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 markup source code and edited into the markup for the Web page. The HierarchicalDataBoundControlDesigner class provides design-time support for controls that are derived from the HierarchicalDataBoundControl in a designer host.

The HierarchicalDataBoundControlDesigner class properties provide the following functionality:

The HierarchicalDataBoundControlDesigner class methods provide the following functionality:

The following code example shows how to extend the HierarchicalDataBoundControlDesigner class to change the appearance of controls that are derived from the HierarchicalDataBoundControl control at design time.

The example derives the MyHierarchicalDataBoundControl class from the HierarchicalDataBoundControl. The MyHierarchicalDataBoundControl class is simply a copy of the HierarchicalDataBoundControl. The example also derives the MyHierarchicalDataBoundControlDesigner class from the HierarchicalDataBoundControlDesigner class and places a DesignerAttribute object for the MyHierarchicalDataBoundControlDesigner on the MyHierarchicalDataBoundControl class.

The MyHierarchicalDataBoundControlDesigner overrides the PreFilterProperties method to make the NamingContainer property visible in the Properties grid at design time. It overrides the GetDesignTimeHtml method to generate the markup for a placeholder if the design time markup is Nothing or Empty, or if the design-time markup is an empty <span> block (that is, if there is no inner markup between the <span> and </span> tags).

Imports System
Imports System.IO
Imports System.Web
Imports System.Drawing
Imports System.Web.UI.WebControls
Imports System.Web.UI.Design.WebControls
Imports System.Collections
Imports System.ComponentModel
Imports System.Security.Permissions

Namespace Examples.VB.WebControls.Design

    ' The MyHierarchicalDataBoundControl is a copy of the  
    ' HierarchicalDataBoundControl.
    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <Designer(GetType(Examples.VB.WebControls.Design. _
        MyHierarchicalDataBoundControlDesigner))> _
    Public Class MyHierarchicalDataBoundControl
        Inherits HierarchicalDataBoundControl
    End Class ' MyHierarchicalDataBoundControl

    ' Override members of the HierarchicalDataBoundControlDesigner.
    <ReflectionPermission(SecurityAction.Demand, Flags:=ReflectionPermissionFlag.MemberAccess)> _
    Public Class MyHierarchicalDataBoundControlDesigner
        Inherits HierarchicalDataBoundControlDesigner

        Private Const bracketClose As String = ">" 
        Private Const spanOpen As String = "<SPAN" 
        Private Const spanClose As String = "</SPAN>" 

        ' Return the markup for a placeholder, if the inner markup is empty. 
        ' For brevity, the code that is used to detect embedded white_space  
        ' in the tags is not shown. 
        Public Overrides Function GetDesignTimeHtml() As String 

            ' Get the design-time markup from the base method. 
            Dim markup As String = MyBase.GetDesignTimeHtml()

            ' If the markup is null or empty, return the markup  
            ' for the placeholder. 
            If markup Is Nothing OrElse markup = String.Empty Then 
                Return GetEmptyDesignTimeHtml()
            End If 

            ' Make the markup uniform case so that the IndexOf will work. 
            Dim markupUC As String = markup.ToUpper()
            Dim charX As Integer 

            ' Look for a <span ...> tag.
            charX = markupUC.IndexOf(spanOpen)
            If charX >= 0 Then 

                ' Find closing bracket of span open tag.
                charX = markupUC.IndexOf(bracketClose, charX + spanOpen.Length)
                If charX >= 0 Then 

                    ' If the inner markup of <span ...></span> is empty,  
                    ' return the markup for a placeholder. 
                    If String.Compare(markupUC, charX + 1, _
                        spanClose, 0, spanClose.Length) = 0 Then 

                        Return GetEmptyDesignTimeHtml()
                    End If 
                End If 
            End If 

            ' Return the original markup, if the inner markup is not empty. 
            Return markup
        End Function ' GetDesignTimeHtml

        ' Shadow the control properties with design-time properties. 
        Protected Overrides Sub PreFilterProperties( _
            ByVal properties As IDictionary)

            Dim namingContainer As String = "NamingContainer" 

            ' Call the base method first. 
            MyBase.PreFilterProperties(properties)

            ' Make the NamingContainery visible in the Properties grid. 
            Dim selectProp As PropertyDescriptor = _
                CType(properties(namingContainer), PropertyDescriptor)
            properties(namingContainer) = _
                TypeDescriptor.CreateProperty(selectProp.ComponentType, _
                    selectProp, BrowsableAttribute.Yes)
        End Sub ' PreFilterProperties
    End Class ' MyHierarchicalDataBoundControlDesigner
End Namespace ' Examples.VB.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
Show: