TagPrefixCollection 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
包含一組 TagPrefixInfo 物件。
public ref class TagPrefixCollection sealed : System::Configuration::ConfigurationElementCollection
[System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.TagPrefixInfo), AddItemName="add", CollectionType=System.Configuration.ConfigurationElementCollectionType.BasicMap)]
public sealed class TagPrefixCollection : System.Configuration.ConfigurationElementCollection
[<System.Configuration.ConfigurationCollection(typeof(System.Web.Configuration.TagPrefixInfo), AddItemName="add", CollectionType=System.Configuration.ConfigurationElementCollectionType.BasicMap)>]
type TagPrefixCollection = class
inherit ConfigurationElementCollection
Public NotInheritable Class TagPrefixCollection
Inherits ConfigurationElementCollection
- 繼承
- 屬性
範例
以下設定檔摘錄展示了如何宣告式地指定該類型多個屬性 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="MyControl.ascx"/>
</controls>
</pages>
</system.web>
以下程式碼範例展示了如何利用該 TagPrefixCollection 類別程式化修改標籤前綴設定。 此程式碼範例是本類別更大範例 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 中與必須包含的組件與命名空間關聯一個「命名空間」,以讓自訂控制項與使用者控制項正常運作。
TagPrefixInfo 物件會被儲存為物件的 TagPrefixCollection 成員。 這個 TagPrefixCollection 類別允許你程式化地存取並修改 controls 設定檔該 pages 區段的子節。
建構函式
| 名稱 | Description |
|---|---|
| TagPrefixCollection() |
建立一個新的類別實例 TagPrefixCollection 。 |
屬性
方法
明確介面實作
| 名稱 | Description |
|---|---|
| ICollection.CopyTo(Array, Int32) |
將 ConfigurationElementCollection 複製到陣列。 (繼承來源 ConfigurationElementCollection) |
擴充方法
| 名稱 | Description |
|---|---|
| AsParallel(IEnumerable) |
啟用查詢的平行處理。 |
| AsQueryable(IEnumerable) |
將 IEnumerable 轉換成 IQueryable。 |
| Cast<TResult>(IEnumerable) |
將 IEnumerable 的項目轉換成指定的型別。 |
| OfType<TResult>(IEnumerable) |
根據指定的型別篩選 IEnumerable 的專案。 |