Export (0) Print
Expand All
0 out of 1 rated this helpful - Rate this topic

Reference a custom ASP.NET control

To work with a custom ASP.NET control in an ASP.NET page, you must reference the custom control in either the page, the master page assigned to the page, or a web.config file. Referencing the custom control in a web.config file is useful if you want to use the custom control in multiple pages of your website.

Cc294876.alert_note(en-us,Expression.10).gifNote:

To work with custom ASP.NET controls in Microsoft Expression Web, you also need to make the custom control available to Expression Web and add the custom control to the Code view of your page. See Add a custom ASP.NET control to a website and Add a custom ASP.NET control to a page.

To reference a custom ASP.NET control in an ASP.NET page

  1. Display your page in Code or Split view.

  2. In the code pane, add the following line of code at the beginning of the page:

    <%@ Register assembly="ASSEMBLY_NAME" namespace="ASSEMBLY_NAMESPACE" tagprefix="TAG_PREFIX" %>
    
  3. In the line of code you added in the previous step, replace ASSEMBLY_NAME with the name of the custom control assembly file, excluding the file extension; replace ASSEMBLY_NAMESPACE with the value specified in the documentation for your custom control; and replace TAG_PREFIX with any name without spaces.

    Cc294876.alert_note(en-us,Expression.10).gifNote:

    If the custom control is installed in the Global Assembly Cache (GAC) on your computer instead of placed in the bin folder of your website, replace ASSEMBLY_NAMESPACE with the fully qualified type name, version, public key token, and culture for your control. For more information, see @Register in the MSDN library.

To reference a custom ASP.NET control in a web.config file

  1. Open your website's web.config file.

    If your website doesn't have a web.config file, create one and save it in the root folder of your website. For information, seeCreate a web configuration file.

  2. If the web.config file doesn't already contain <pages> <controls> </pages></controls> tags, add them after the <system.web> tag and before the </system.web> tag.

  3. Add the following code anywhere after the <system.web><pages><controls> tags and before the </system.web></pages></controls> tags:

    <add tagprefix="TAG_PREFIX" assembly="ASSEMBLY_NAME" namespace="ASSEMBLY_NAMESPACE" />
    
  4. Replace ASSEMBLY_NAME with the name of the custom control assembly file, excluding the file extension; replace TAG_PREFIX with any name without spaces; and replace ASSEMBLY_NAMESPACE with the value specified in the documentation for your custom control.

    Cc294876.alert_note(en-us,Expression.10).gifNote:

    If the custom control is installed in the Global Assembly Cache (GAC) on your computer instead of placed in the bin folder of your website, replace ASSEMBLY_NAMESPACE with the fully qualified type name, version, public key token, and culture for your control. For more information, see @Register in the MSDN library.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.