TagPrefixInfo クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
タグ関連情報が格納される構成要素を定義します。
public ref class TagPrefixInfo sealed : System::Configuration::ConfigurationElement
public sealed class TagPrefixInfo : System.Configuration.ConfigurationElement
type TagPrefixInfo = class
inherit ConfigurationElement
Public NotInheritable Class TagPrefixInfo
Inherits ConfigurationElement
- 継承
例
この例では、 セクションのいくつかの属性に対して宣言的に値を controls 指定する方法を示します。これは、 クラスの TagPrefixInfo メンバーとしてもアクセスできます。
<system.web>
<pages>
<controls>
<!-- Searches all linked assemblies for the namespace -->
<add tagPrefix="MyTags1" namespace=" MyNameSpace "/>
<!-- Uses a specified assembly -->
<add tagPrefix="MyTags2" namespace="MyNameSpace"
assembly="MyAssembly"/>
<!-- Uses the specified source for the user control -->
<add tagprefix="MyTags3" tagname="MyCtrl" src="MyControl.ascx"/>
</controls>
</pages>
</system.web>
次のコード例は、 クラスを使用 TagPrefixInfo してプログラムでタグ プレフィックスの設定を変更する方法を示しています。 このコード例は、PagesSection クラスのために提供されている大規模な例の一部です。
// Get all current Controls in the collection.
for (int i = 0; i < pagesSection.Controls.Count; i++)
{
Console.WriteLine("Control {0}:", i);
Console.WriteLine(" TagPrefix = '{0}' ",
pagesSection.Controls[i].TagPrefix);
Console.WriteLine(" TagName = '{0}' ",
pagesSection.Controls[i].TagName);
Console.WriteLine(" Source = '{0}' ",
pagesSection.Controls[i].Source);
Console.WriteLine(" Namespace = '{0}' ",
pagesSection.Controls[i].Namespace);
Console.WriteLine(" Assembly = '{0}' ",
pagesSection.Controls[i].Assembly);
}
// Create a new TagPrefixInfo object.
System.Web.Configuration.TagPrefixInfo tagPrefixInfo =
new System.Web.Configuration.TagPrefixInfo("MyCtrl", "MyNameSpace", "MyAssembly", "MyControl", "MyControl.ascx");
// Execute the Add Method.
pagesSection.Controls.Add(tagPrefixInfo);
// Add a TagPrefixInfo object using a constructor.
pagesSection.Controls.Add(
new System.Web.Configuration.TagPrefixInfo(
"MyCtrl", "MyNameSpace", "MyAssembly", "MyControl",
"MyControl.ascx"));
' Get all current Controls in the collection.
Dim j As Int32
For j = 0 To pagesSection.Controls.Count - 1
Console.WriteLine("Control {0}:", j)
Console.WriteLine(" TagPrefix = '{0}' ", _
pagesSection.Controls(j).TagPrefix)
Console.WriteLine(" TagName = '{0}' ", _
pagesSection.Controls(j).TagName)
Console.WriteLine(" Source = '{0}' ", _
pagesSection.Controls(j).Source)
Console.WriteLine(" Namespace = '{0}' ", _
pagesSection.Controls(j).Namespace)
Console.WriteLine(" Assembly = '{0}' ", _
pagesSection.Controls(j).Assembly)
Next
' Create a new TagPrefixInfo object.
Dim tagPrefixInfo As System.Web.Configuration.TagPrefixInfo = _
New System.Web.Configuration.TagPrefixInfo("MyCtrl", "MyNameSpace", "MyAssembly", "MyControl", "MyControl.ascx")
' Execute the Add Method.
pagesSection.Controls.Add(tagPrefixInfo)
' Add a TagPrefixInfo object using a constructor.
pagesSection.Controls.Add( _
New System.Web.Configuration.TagPrefixInfo( _
"MyCtrl", "MyNameSpace", "MyAssembly", "MyControl", _
"MyControl.ascx"))
注釈
TagPrefixInfoクラスを使用すると、構成ファイルに格納されているタグプレフィックス情報にプログラムでアクセスして変更できます。 ASP.NET @Register ディレクティブと同じ機能が提供されます。 タグ プレフィックスは、カスタム コントロールとユーザー コントロールが正常に動作するために含める必要があるアセンブリと名前空間に、ASP.NET の "名前空間" を関連付けます。
TagPrefixInfo オブジェクトは、 オブジェクトの TagPrefixCollection メンバーとして格納されます。
TagPrefixCollectionクラスを使用すると、構成ファイルの セクションのpagesサブセクションにcontrolsプログラムでアクセスして変更できます。
TagPrefixInfo オブジェクトは、 要素を使用して add コレクションに追加され、属性の値と他の tagPrefix 関連する属性の値を指定します。 その他の必要な情報は、指定したタグ プレフィックスで使用するコントロールの種類によって異なります。
ユーザー コントロールの場合は、および Source の各プロパティをTagPrefixTagName定義する必要があります。
カスタム コントロールの場合は、および Assembly プロパティを定義するTagPrefixNamespace必要があります。 Assemblyコントロールがアプリケーション コード ディレクトリにある場合、プロパティは必要ありません。
同じ tagPrefix 値を使用して、複数のアセンブリまたは名前空間にマップできます。
注意
ソースを指定する場合、ユーザー コントロール自体がページと同じディレクトリに存在してはなりません。 その場合は、ページを読み込もうとしたときに実行時エラーが発生します。
コンストラクター
| 名前 | 説明 |
|---|---|
| TagPrefixInfo(String, String, String, String, String) |
渡された値を使用して、TagPrefixInfo クラスの新しいインスタンスを初期化します。 |
プロパティ
| 名前 | 説明 |
|---|---|
| Assembly |
コントロールの実装を格納しているアセンブリの名前を取得または設定します。 |
| CurrentConfiguration |
現在の Configuration インスタンスが属している構成階層を表す最上位の ConfigurationElement インスタンスへの参照を取得します。 (継承元 ConfigurationElement) |
| ElementInformation |
ElementInformation オブジェクトのカスタマイズできない情報と機能を格納する ConfigurationElement オブジェクトを取得します。 (継承元 ConfigurationElement) |
| ElementProperty |
ConfigurationElementProperty オブジェクト自体を表す ConfigurationElement オブジェクトを取得します。 (継承元 ConfigurationElement) |
| EvaluationContext |
ContextInformation オブジェクトの ConfigurationElement オブジェクトを取得します。 (継承元 ConfigurationElement) |
| HasContext |
CurrentConfiguration プロパティが |
| Item[ConfigurationProperty] |
この構成要素のプロパティまたは属性を取得または設定します。 (継承元 ConfigurationElement) |
| Item[String] |
この構成要素のプロパティ、属性、または子要素を取得または設定します。 (継承元 ConfigurationElement) |
| LockAllAttributesExcept |
ロックされている属性のコレクションを取得します。 (継承元 ConfigurationElement) |
| LockAllElementsExcept |
ロックされている要素のコレクションを取得します。 (継承元 ConfigurationElement) |
| LockAttributes |
ロックされている属性のコレクションを取得します。 (継承元 ConfigurationElement) |
| LockElements |
ロックされている要素のコレクションを取得します。 (継承元 ConfigurationElement) |
| LockItem |
要素がロックされているかどうかを示す値を取得または設定します。 (継承元 ConfigurationElement) |
| Namespace |
コントロールが存在する名前空間を取得または設定します。 |
| Properties |
プロパティのコレクションを取得します。 (継承元 ConfigurationElement) |
| Source |
ユーザー コントロールを含むファイルの名前とパスを取得または設定します。 |
| TagName |
ユーザー コントロールの名前を取得または設定します。 |
| TagPrefix |
ソース ファイルまたは名前空間とアセンブリに関連付けられるタグ プリフィックスを取得または設定します。 |