TagPrefixCollection クラス
アセンブリ: System.Web (system.web.dll 内)


TagPrefixInfo クラスを使用すると、構成ファイルに格納されているタグ プリフィックス情報にプログラムからアクセスして変更できます。タグ プレフィックスは、カスタム コントロールやユーザー コントロールが適切に動作するために含める必要があるアセンブリや名前空間に、ASP.NET の "名前空間" を関連付けます。
TagPrefixInfo オブジェクトは、TagPrefixCollection オブジェクトのメンバとして格納されます。TagPrefixCollection クラスを使用すると、構成ファイル内の pages セクションの controls サブセクションにプログラムからアクセスして変更できます。

以下は構成ファイルからの抜粋です。TagPrefixCollection 型の複数のプロパティに対して、宣言によって値を指定する方法を示しています。
<system.web> <pages> <controls> <clear /> <remove tagPrefix="MyTags" /> <!—- 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="https://cdn.weblio.jp/e7/img/dict/msdnc/MyControl.ascx"/> </controls> </pages> </system.web>
TagPrefixCollection クラスを使用して、プログラムからタグ プレフィックス設定を変更する方法を次のコード例に示します。このコード例は、PagesSection クラスのトピックで取り上げているコード例の一部分です。
' 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"))
// 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"));

System.Configuration.ConfigurationElement
System.Configuration.ConfigurationElementCollection
System.Web.Configuration.TagPrefixCollection


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- TagPrefixCollection クラスのページへのリンク