ConstructorNeedsTagAttribute.NeedsTag Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Indicates whether a control needs a tag name in its constructor. This property is read-only.
public:
property bool NeedsTag { bool get(); };
public bool NeedsTag { get; }
member this.NeedsTag : bool
Public ReadOnly Property NeedsTag As Boolean
Property Value
true
if the control needs a tag in its constructor. The default is false
.
Examples
// 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.
<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
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
End Class
Applies to
שתף איתנו פעולה ב- GitHub
ניתן למצוא את המקור לתוכן זה ב- GitHub, שם ניתן גם ליצור ולסקור בעיות ולמשוך בקשות. לקבלת מידע נוסף, עיין במדריך התורמים שלנו.