Freigeben über


ControlBuilder.ControlType-Eigenschaft

Ruft den Type für das zu erstellende Steuerelement ab.

Namespace: System.Web.UI
Assembly: System.Web (in system.web.dll)

Syntax

'Declaration
Public ReadOnly Property ControlType As Type
'Usage
Dim instance As ControlBuilder
Dim value As Type

value = instance.ControlType
public Type ControlType { get; }
public:
property Type^ ControlType {
    Type^ get ();
}
/** @property */
public Type get_ControlType ()
public function get ControlType () : Type

Eigenschaftenwert

Der Type für das zu erstellende Steuerelement.

Beispiel

In diesem Beispiel wird die OnAppendToParentBuilder-Methode überschrieben, um anhand einer Überprüfung der ControlType-Eigenschaft zu bestimmen, auf welchen Steuerelementtyp dieser Generator angewendet wird. Im Falle einer CustomTextBox überprüft der Generator, ob der Wert der HasAspCode-Eigenschaft im Steuerelement enthalten ist. Wenn dies der Fall ist, wird eine Ausnahme ausgelöst, ansonsten wird die HasBody-Methode aufgerufen.

Imports System
Imports System.Web.UI
Imports System.Web
Imports System.Security.Permissions

Namespace ASPNET.Samples

   <AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)> _
   Public NotInheritable Class AppendControlBuilder
      Inherits ControlBuilder

      ' Override the OnAppendToParentBuilder method.
      Overrides Public Sub OnAppendToParentBuilder( _
         ByVal parentBuilder As ControlBuilder _
      )
            ' Check whether the type of the control this builder
            ' is applied to is CustomTextBox. If so, check whether
            ' ASP code blocks exist in the control. If so, call
            ' throw an Exception, if not, call the HasBody method.        
            If ControlType Is Type.GetType("CustomTextBox") Then
                If HasAspCode = True Then
                    Throw New Exception("This control cannot contain code blocks.")
                Else
                    HasBody()
                End If
            End If

        End Sub

   End Class

End Namespace
using System;
using System.Web.UI;
using System.Web;
using System.Security.Permissions;

namespace ASPNET.Samples
{
    [
    AspNetHostingPermission(SecurityAction.Demand,
        Level=AspNetHostingPermissionLevel.Minimal)
    ]
    public class AppendControlBuilder : ControlBuilder
    {
        // Override the OnAppendToParentBuilder method.
        public override void OnAppendToParentBuilder(ControlBuilder parentBuilder)
        {
            // Check whether the type of the control this builder
            // is applied to is CustomTextBox. If so, check whether
            // ASP code blocks exist in the control. If so, call
            // throw an Exception, if not, call the HasBody method.        
            if (ControlType == Type.GetType("CustomTextBox"))
            {
                if (HasAspCode)
                    throw new Exception("This control cannot contain code blocks.");
                else
                    HasBody();
            }
        }
    }
}

Plattformen

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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ControlBuilder-Klasse
ControlBuilder-Member
System.Web.UI-Namespace
Type