Freigeben über


ConstructorNeedsTagAttribute.NeedsTag-Eigenschaft

Gibt an, ob ein Steuerelement in seinem Konstruktor einen Tagnamen benötigt. Diese Eigenschaft ist schreibgeschützt.

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

Syntax

'Declaration
Public ReadOnly Property NeedsTag As Boolean
'Usage
Dim instance As ConstructorNeedsTagAttribute
Dim value As Boolean

value = instance.NeedsTag
public bool NeedsTag { get; }
public:
property bool NeedsTag {
    bool get ();
}
/** @property */
public boolean get_NeedsTag ()
public function get NeedsTag () : boolean

Eigenschaftenwert

true, wenn das Steuerelement in seinem Konstruktor ein Tag benötigt. Der Standardwert ist false.

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

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-Klasse
ConstructorNeedsTagAttribute-Member
System.Web.UI-Namespace