PagesSection.Controls 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得 TagPrefixInfo 物件的集合。
public:
property System::Web::Configuration::TagPrefixCollection ^ Controls { System::Web::Configuration::TagPrefixCollection ^ get(); };
[System.Configuration.ConfigurationProperty("controls")]
public System.Web.Configuration.TagPrefixCollection Controls { get; }
[<System.Configuration.ConfigurationProperty("controls")>]
member this.Controls : System.Web.Configuration.TagPrefixCollection
Public ReadOnly Property Controls As TagPrefixCollection
屬性值
TagPrefixCollection 物件的 TagPrefixInfo。
- 屬性
範例
下列程式碼範例示範如何使用 Controls 屬性。
// 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物件會對應至 @ Register
ASP.NET 網頁上的 指示詞。 指示 @ Register
詞可讓您指定使用者控制項的標記前置詞。