Freigeben über


ConstructorNeedsTagAttribute-Klasse

Gibt an, dass ein Serversteuerelement in seinem Konstruktor einen Tagnamen benötigt.

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

Syntax

'Declaration
<AttributeUsageAttribute(AttributeTargets.Class)> _
Public NotInheritable Class ConstructorNeedsTagAttribute
    Inherits Attribute
'Usage
Dim instance As ConstructorNeedsTagAttribute
[AttributeUsageAttribute(AttributeTargets.Class)] 
public sealed class ConstructorNeedsTagAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Class)] 
public ref class ConstructorNeedsTagAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class) */ 
public final class ConstructorNeedsTagAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class) 
public final class ConstructorNeedsTagAttribute extends Attribute

Hinweise

Hintergrundinformationen finden Sie unter Erweitern von Metadaten mithilfe von Attributen.

Beispiel

' Attach the ConstructorNeedsTagAttribute to the custom Simple
' class, which is derived from the WebControl class. This 
' instance of the ConstructorNeedsTagAttribute class sets the
' NeedsTag property to true.
<ConstructorNeedsTagAttribute(True)>  _
<AspNetHostingPermission(SecurityAction.Demand, _
  Level:=AspNetHostingPermissionLevel.Minimal)> _
Public NotInheritable Class Simple
  Inherits WebControl

  Private NameTag As String = ""
  
  
  Public Sub New(tag As String)
     Me.NameTag = tag
  End Sub 'New
  
  Private UserMessage As String = Nothing
  
  ' Create a property named ControlValue.   
  Public Property ControlValue() As [String]
     Get
        Return UserMessage
     End Get
     Set
        UserMessage = value
     End Set
  End Property
     
  Protected Overrides Sub Render(output As HtmlTextWriter)
     output.Write("Testing the ConstructorNeedsTagAttribute Class.")
  End Sub 'Render
End Class 'Simple
  // Attach the ConstructorNeedsTagAttribute to the custom Simple
  // class, which is derived from the WebControl class. This 
  // instance of the ConstructorNeedsTagAttribute class sets the
  // NeedsTag property to true.
  [ConstructorNeedsTagAttribute(true)]
  [AspNetHostingPermission(SecurityAction.Demand, 
     Level=AspNetHostingPermissionLevel.Minimal)]
  public sealed class Simple : WebControl 
  {
     private String NameTag = "";

     public Simple(String tag)
      {
            this.NameTag = tag;
      }         

      private String   UserMessage = null;

      // Create a property named ControlValue.
      public String ControlValue 
      {
         get 
         {
            return UserMessage;
         }
         set 
         {
            UserMessage = value;
         }
      }                



      protected override void Render(HtmlTextWriter output) 
      {
         output.Write("Testing the ConstructorNeedsTagAttribute Class.");
      }
}      
// Attach the ConstructorNeedsTagAttribute to the custom Simple
// class, which is derived from the WebControl class. This 
// instance of the ConstructorNeedsTagAttribute class sets the
// NeedsTag property to true.

/** @attribute ConstructorNeedsTagAttribute(true)
 */
public class Simple extends WebControl
{
    private String nameTag = "";

    public Simple(String tag)
    {
        this.nameTag = tag;
    } //Simple

    private String userMessage = null;
    // Create a property named ControlValue.
    /** @property 
     */
    public String get_ControlValue()
    {
        return userMessage;
    } //get_ControlValue
    /** @property 
     */
    public void set_ControlValue(String value)
    {
        userMessage = value;
    } //set_ControlValue

    protected void Render(HtmlTextWriter output)
    {
        output.Write("Testing the ConstructorNeedsTagAttribute Class.");
    } //Render
} //Simple

Vererbungshierarchie

System.Object
   System.Attribute
    System.Web.UI.ConstructorNeedsTagAttribute

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

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

ConstructorNeedsTagAttribute-Member
System.Web.UI-Namespace
Attribute