TagPrefixAttribute クラスの新しいインスタンスを初期化します。
名前空間: System.Web.UI
アセンブリ: System.Web (system.web.dll 内)
構文
'宣言
Public Sub New ( _
namespaceName As String, _
tagPrefix As String _
)
'使用
Dim namespaceName As String
Dim tagPrefix As String
Dim instance As New TagPrefixAttribute(namespaceName, tagPrefix)
public TagPrefixAttribute (
string namespaceName,
string tagPrefix
)
public:
TagPrefixAttribute (
String^ namespaceName,
String^ tagPrefix
)
public TagPrefixAttribute (
String namespaceName,
String tagPrefix
)
public function TagPrefixAttribute (
namespaceName : String,
tagPrefix : String
)
適用できません。
パラメータ
- namespaceName
カスタム コントロールの名前空間を識別する文字列。
- tagPrefix
カスタム コントロールのプリフィックスを識別する文字列。
例外
例外の種類 | 条件 |
---|---|
namespaceName または tagPrefix が null 参照 (Visual Basic では Nothing) または空の文字列 ("") です。 |
解説
カスタム コントロールを定義するときは、コードの前に、このクラス コンストラクタを次のように呼び出す必要があります。
[assembly:TagPrefix(namespace, tag)]
使用例
カスタム コントロールのタグ プリフィックス エイリアスを指定するために使用できるアセンブリ レベルの属性を定義する方法を次のコード例に示します。この属性は、カスタム コントロールが使用される Web ページで @ Register ディレクティブを自動的に生成するために、Microsoft Visual Studio などのツールで使用されます。
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
<assembly: TagPrefix("CustomControls", "custom")> _
Namespace CustomControls
' Simple custom control
Public Class MyVB_Control
Inherits Control
Private message As String = "Hello"
Public Property getMessage() As String
Get
Return message
End Get
Set (ByVal value As String)
message = value
End Set
End Property
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
Protected Overrides Sub Render(writer As HtmlTextWriter)
writer.Write(("<span style='background-color:aqua; font:8pt tahoma, verdana;'> " + Me.getMessage + "<br>" + "VB version. The time on the server is " + System.DateTime.Now.ToLongTimeString() + "</span>"))
End Sub 'Render
End Class 'MyControl
End Namespace 'CustomControls
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
[assembly:TagPrefix("CustomControls", "custom")]
namespace CustomControls
{
// Simple custom control
public class MyCS_Control : Control
{
private String message = "Hello";
public virtual String Message
{
get
{
return message;
}
set
{
message = value;
}
}
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand, Name="FullTrust")]
protected override void Render( HtmlTextWriter writer)
{
writer.Write("<span style='background-color:aqua; font:8pt tahoma, verdana;'> "
+ this.Message + "<br>" + "C# version. The time on the server is " + System.DateTime.Now.ToLongTimeString()
+ "</span>");
}
}
}
import System.*;
import System.Web.*;
import System.Web.UI.*;
import System.Web.UI.WebControls.*;
/** @assembly TagPrefix("CustomControls", "custom")
*/
// Simple custom control
public class MyJSL_Control extends Control
{
private String message = "Hello";
/** @property
*/
public String get_Message()
{
return message;
} //get_Message
/** @property
*/
public void set_Message(String value)
{
message = value;
} //set_Message
protected void Render(HtmlTextWriter writer)
{
writer.Write("<span style='background-color:aqua; font:8pt"
+ " tahoma, verdana;'> " + this.get_Message() + "<br>"
+ "VJ# version. The time on the server is "
+ System.DateTime.get_Now().ToLongTimeString() + "</span>");
} //Render
} //MyJSL_Control
プラットフォーム
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
参照
関連項目
TagPrefixAttribute クラス
TagPrefixAttribute メンバ
System.Web.UI 名前空間