コントロールのコンストラクタにタグ名が必要かどうかを示します。このプロパティは読み取り専用です。
Public ReadOnly Property NeedsTag As Boolean
[C#]
public bool NeedsTag {get;}
[C++]
public: __property bool get_NeedsTag();
[JScript]
public function get NeedsTag() : Boolean;
プロパティ値
コントロールのコンストラクタにタグが必要な場合は true 。既定値は false です。
使用例
' 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] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン
をクリックします。
必要条件
プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ
参照
ConstructorNeedsTagAttribute クラス | ConstructorNeedsTagAttribute メンバ | System.Web.UI 名前空間