Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Controls Property

PagesSection.Controls Property

Gets a collection of TagPrefixInfo objects.

Namespace:  System.Web.Configuration
Assembly:  System.Web (in System.Web.dll)

'Declaration
<ConfigurationPropertyAttribute("controls")> _
Public ReadOnly Property Controls As TagPrefixCollection

The TagPrefixInfo objects correspond to the @ Register directive on an ASP.NET page. The @ Register directive allows you to specify the tag prefix for a user control.

The following code example shows how to use the Controls property.

' 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"))

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0
Show:
© 2015 Microsoft