共用方式為


TagPrefixInfo 類別

定義

定義包含標籤相關資訊的組態元素。

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 類別允許你程式化地存取並修改 controls 設定檔該 pages 區段的子節。

TagPrefixInfo 物件會透過元素 add 加入集合,並指定 tagPrefix 屬性值及其他相關屬性的值。 其他必要資訊會依你將使用指定標籤前綴的控制類型而有所不同:

相同的 tagPrefix 值可用來映射到多個組件或命名空間。

備註

當指定來源時,使用者控制項本身不得與頁面同一個目錄。 如果是,當你嘗試載入頁面時會跳出執行時錯誤。

建構函式

名稱 Description
TagPrefixInfo(String, String, String, String, String)

利用傳遞的值初始化該類別的新 TagPrefixInfo 實例。

屬性

名稱 Description
Assembly

取得或設定包含控制實作的組裝體名稱。

CurrentConfiguration

會取得代表該Configuration實例所屬配置階層的頂層ConfigurationElement實例參考。

(繼承來源 ConfigurationElement)
ElementInformation

取得 ElementInformation 一個包含不可自訂資訊與功能的 ConfigurationElement 物件。

(繼承來源 ConfigurationElement)
ElementProperty

取得 ConfigurationElementProperty 代表該 ConfigurationElement 物件本身的物件。

(繼承來源 ConfigurationElement)
EvaluationContext

取得 ContextInformation 物件的 ConfigurationElement 物件。

(繼承來源 ConfigurationElement)
HasContext

獲得一個表示該 CurrentConfiguration 性質是否為 null的值。

(繼承來源 ConfigurationElement)
Item[ConfigurationProperty]

取得或設定此組態元素的屬性或屬性。

(繼承來源 ConfigurationElement)
Item[String]

取得或設定該配置元素的屬性、屬性或子元素。

(繼承來源 ConfigurationElement)
LockAllAttributesExcept

取得鎖定屬性的集合。

(繼承來源 ConfigurationElement)
LockAllElementsExcept

獲得鎖定元素的集合。

(繼承來源 ConfigurationElement)
LockAttributes

取得鎖定屬性的集合。

(繼承來源 ConfigurationElement)
LockElements

獲得鎖定元素的集合。

(繼承來源 ConfigurationElement)
LockItem

取得或設定一個值,表示該元素是否被鎖定。

(繼承來源 ConfigurationElement)
Namespace

取得或設定控制項所在的命名空間。

Properties

取得一組房產。

(繼承來源 ConfigurationElement)
Source

取得或設定包含使用者控制項的檔案名稱與路徑。

TagName

取得或設定使用者控制項的名稱。

TagPrefix

取得或設定與原始檔案或命名空間及組合語言相關聯的標籤前綴。

方法

名稱 Description
DeserializeElement(XmlReader, Boolean)

從設定檔讀取 XML。

(繼承來源 ConfigurationElement)
Equals(Object)

將此實例與另一個物件進行比較。

GetHashCode()

回傳目前實例的雜湊值。

GetTransformedAssemblyString(String)

回傳指定的組裝名稱轉換後版本。

(繼承來源 ConfigurationElement)
GetTransformedTypeString(String)

回傳指定型別名稱的轉換後版本。

(繼承來源 ConfigurationElement)
GetType()

取得目前實例的 Type

(繼承來源 Object)
Init()

將物件設定 ConfigurationElement 為初始狀態。

(繼承來源 ConfigurationElement)
InitializeDefault()

用於初始化物件的預設值 ConfigurationElement 集合。

(繼承來源 ConfigurationElement)
IsModified()

表示此組態元素自最後儲存或載入後是否被修改,且實作於衍生類別中。

(繼承來源 ConfigurationElement)
IsReadOnly()

會取得一個值,表示該物件是否 ConfigurationElement 為唯讀。

(繼承來源 ConfigurationElement)
ListErrors(IList)

將此 ConfigurationElement 物件及所有子元素中的無效屬性錯誤加入已傳遞的清單中。

(繼承來源 ConfigurationElement)
MemberwiseClone()

建立目前 Object的淺層複本。

(繼承來源 Object)
OnDeserializeUnrecognizedAttribute(String, String)

獲得一個值,表示在反序列化過程中是否遇到未知屬性。

(繼承來源 ConfigurationElement)
OnDeserializeUnrecognizedElement(String, XmlReader)

會獲得一個值,表示在反序列化過程中是否遇到未知元素。

(繼承來源 ConfigurationElement)
OnRequiredPropertyNotFound(String)

當找不到所需的屬性時,會拋出例外。

(繼承來源 ConfigurationElement)
PostDeserialize()

在解序後被呼叫。

(繼承來源 ConfigurationElement)
PreSerialize(XmlWriter)

在序列號之前就被打過。

(繼承來源 ConfigurationElement)
Reset(ConfigurationElement)

重置物件的 ConfigurationElement 內部狀態,包括鎖與屬性集合。

(繼承來源 ConfigurationElement)
ResetModified()

在導出類別實作時,將方法的值IsModified()重置為 。false

(繼承來源 ConfigurationElement)
SerializeElement(XmlWriter, Boolean)

當在衍生類別中實作時,會將此組態元素的內容寫入設定檔。

(繼承來源 ConfigurationElement)
SerializeToXmlElement(XmlWriter, String)

當在衍生類別中實作時,會將此組態元素的外部標籤寫入設定檔。

(繼承來源 ConfigurationElement)
SetPropertyValue(ConfigurationProperty, Object, Boolean)

將屬性設定為指定的值。

(繼承來源 ConfigurationElement)
SetReadOnly()

設定 IsReadOnly() 物件及所有子元素的 ConfigurationElement 屬性。

(繼承來源 ConfigurationElement)
ToString()

傳回表示目前 物件的字串。

(繼承來源 Object)
Unmerge(ConfigurationElement, ConfigurationElement, ConfigurationSaveMode)

修改物件 ConfigurationElement 以移除所有不應儲存的值。

(繼承來源 ConfigurationElement)

適用於

另請參閱