ConstructorNeedsTagAttribute クラスの新しいインスタンスを初期化します。
名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
Public Sub New ( _
needsTag As Boolean _
)
'使用
Dim needsTag As Boolean
Dim instance As New ConstructorNeedsTagAttribute(needsTag)
public ConstructorNeedsTagAttribute (
bool needsTag
)
public:
ConstructorNeedsTagAttribute (
bool needsTag
)
public ConstructorNeedsTagAttribute (
boolean needsTag
)
public function ConstructorNeedsTagAttribute (
needsTag : boolean
)
適用できません。
パラメータ
- needsTag
タグをコントロールに追加する場合は true。それ以外の場合は false。
使用例
タグ名が実行時に定義される単純なカスタム コントロールを作成するコード例を次に示します。実行可能ファイルを作成するために使用されるコマンド ラインを次に示します。
vbc /r:System.dll /r:System.Web.dll /t:library /out:myWebAppPath/Bin/vb_myconstructorNeedsTagAtt.dll constructNeedsTagAtt.vb
csc /t:library /out:myWebAppPath/Bin/cs_myConstructorNeedsTagAtt.dll constructorNeedsTagAtt.cs
' File name: constructorneedstagatt.cs.
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Namespace MyUserControl
<ConstructorNeedsTagAttribute(True)> _
Public Class Simple
Inherits WebControl
Private NameTag As [String] = ""
Public Sub New(tag As [String])
Me.NameTag = tag
End Sub 'New
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub Render(output As HtmlTextWriter)
output.Write(("<br>The TagName used for the 'Simple' control is " + "'" + NameTag + "'"))
End Sub 'Render
End Class 'Simple
End Namespace 'MyUserControl
/* File Name: constructorneedstagatt.cs. */
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
namespace MyUserControl
{
// Attach the 'ConstructorNeedsTagAttribute' to 'Simple' class.
[ConstructorNeedsTagAttribute(true)]
public class Simple : WebControl
{
private String NameTag = "";
public Simple(String tag)
{
this.NameTag = tag;
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void Render(HtmlTextWriter output)
{
output.Write("<br>The TagName used for the 'Simple' control is "+"'"+NameTag+"'");
}
}
}
package MyUserControl;
/* File Name: constructorneedstagatt.jsl. */
import System.*;
import System.Web.*;
import System.Web.UI.*;
import System.Web.UI.WebControls.*;
import System.ComponentModel.*;
// Attach the 'ConstructorNeedsTagAttribute' to 'Simple' class.
/** @attribute ConstructorNeedsTagAttribute(true)
*/
public class Simple extends WebControl
{
private String nameTag = "";
public Simple(String tag)
{
this.nameTag = tag;
} //Simple
protected void Render(HtmlTextWriter output)
{
output.Write("<br>The TagName used for the 'Simple' control is "
+ "'" + nameTag + "'");
} //Render
} //Simple
前述のカスタム コントロールを使用するコード例を次に示します。Register ディレクティブに示される値には、前のコマンド ラインが反映されます。
<%@ Register TagPrefix='MyCurrentUserControl' Namespace='MyUserControl' Assembly='vb_myConstructorNeedsTagAtt'%>
<html>
<body>
<form method="POST" runat="server">
<MyCurrentUserControl:Simple runat="server" />
</form>
</body>
</html>
<%@ Register TagPrefix='MyCurrentUserControl' Namespace='MyUserControl' Assembly='cs_myConstructorNeedsTagAtt'%>
<html>
<body>
<form method="POST" runat="server">
<MyCurrentUserControl:Simple runat="server" />
</form>
</body>
</html>
プラットフォーム
Windows 98,Windows Server 2000 SP4,Windows CE,Windows Millennium Edition,Windows Mobile for Pocket PC,Windows Mobile for Smartphone,Windows Server 2003,Windows XP Media Center Edition,Windows XP Professional x64 Edition,Windows XP SP2,Windows XP Starter Edition
Microsoft .NET Framework 3.0 は Windows Vista,Microsoft Windows XP SP2,および Windows Server 2003 SP1 でサポートされています。
バージョン情報
.NET Framework
サポート対象 : 3.0,2.0,1.1,1.0
参照
関連項目
ConstructorNeedsTagAttribute クラス
ConstructorNeedsTagAttribute メンバ
System.Web.UI 名前空間