Add a Custom Control (IIS 7)

Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista

Add a custom control when you want to specify the tag prefix/namespace mapping for a custom control that will be used in multiple pages in an application.

noteNote
Adding a configuration setting adds the setting at the local level and to any child levels that inherit the setting.

For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see Custom Controls Feature Requirements (IIS 7).

Exceptions to feature requirements

  • None

You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.

  1. Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI, see Navigation in IIS Manager (IIS 7).

  2. In Features View, double-click Pages and Controls.

  3. In the Actions pane, click Register Controls.

  4. In the Actions pane, click Add Custom Control.

  5. In the Add Custom Control dialog box, type a tag prefix in the Tag prefix text box.

  6. In the Namespace text box, type the namespace to which the custom control belongs. This is the same namespace that was specified in the application code.

  7. In the Assembly text box, type the name of the source or assembly for the custom control, and then click OK.

To add a custom control, use the following syntax:

appcmd set config /commit:WEBROOT /section:system.web/pages /+"controls.[assembly=' string ',namespace=' string ',src=' string ', tagName=' string ', tagPrefix=' string ']"

The variable assembly string is the name of the assembly that contains the COM control implementation and requires that the namespace attribute is also set. The variable namespace string is the namespace that is associated with the tag prefix and requires that the assembly attribute is also set, if the COM control is not located in the application code directory. The variable src string is the name of the file that contains the user control and requires that the tagName attribute is also set. The variable tagName string is the name of the control to use in the page and requires that the src attribute is also set. The variable tagPrefix string is the tag prefix that is being mapped to a source file or namespace and assembly. This attribute requires one of the following combinations of other attributes:

  • namespace to define a COM control, if the control is in the application code directory.

  • namespace and assembly to define a COM control.

  • tagName and src to define a user control.

For example, to add a custom control that uses the specified source for a user control, type the following at the command prompt, and then press Enter:

appcmd set config /commit:WEBROOT /section:system.web/pages /+"controls.[tagPrefix='MyTag', tagName='MyControl',src='controls/MyControl.asx']"

noteNote
When you use Appcmd.exe to configure the <controls> element at the global level in IIS 7, you must specify /commit:WEBROOT in the command so that configuration changes are made to the root Web.config file instead of ApplicationHost.config.

For more information about Appcmd.exe, see Appcmd.exe (IIS 7).

The procedure in this topic affects the following configuration elements:

  • <controls>

For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.

Use the following WMI classes, methods, or properties to perform this procedure:

  • PagesSection.Controls.Add method

For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.

See Also

Community Additions

ADD
Show: