ConstructorNeedsTagAttribute Class
Specifies that a server control needs a tag name in its constructor.
For a list of all members of this type, see ConstructorNeedsTagAttribute Members.
System.Object
System.Attribute
System.Web.UI.ConstructorNeedsTagAttribute
[Visual Basic] <AttributeUsage(AttributeTargets.Class)> NotInheritable Public Class ConstructorNeedsTagAttribute Inherits Attribute [C#] [AttributeUsage(AttributeTargets.Class)] public sealed class ConstructorNeedsTagAttribute : Attribute [C++] [AttributeUsage(AttributeTargets::Class)] public __gc __sealed class ConstructorNeedsTagAttribute : public Attribute [JScript] public AttributeUsage(AttributeTargets.Class) class ConstructorNeedsTagAttribute extends Attribute
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Remarks
For background information, see Extending Metadata Using Attributes.
Example
[Visual Basic] ' 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)> _ Public 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 [C#] // 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)] public 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."); } } [C++] // 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)] public __gc class Simple : public WebControl { private: String* NameTag; public: Simple(String* tag) { this->NameTag = tag; } private: String* UserMessage; // Create a property named ControlValue. public: __property String* get_ControlValue() { return UserMessage; } __property void set_ControlValue(String* value) { UserMessage = value; } protected: void Render(HtmlTextWriter* output) { output->Write(S"Testing the ConstructorNeedsTagAttribute Class."); } };
[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button
in the upper-left corner of the page.
Requirements
Namespace: System.Web.UI
Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family
Assembly: System.Web (in System.Web.dll)
See Also
ConstructorNeedsTagAttribute Members | System.Web.UI Namespace | Attribute