Microsoft KB Archive/321749

= HOW TO: Register an Assembly in a WebForm to Use a Custom Control =

Article ID: 321749

Article Last Modified on 6/17/2003

-

APPLIES TO


 * Microsoft .NET Framework 1.1
 * Microsoft ASP.NET 1.0
 * Microsoft Windows 2000 Standard Edition
 * Microsoft ASP.NET 1.1
 * Microsoft .NET Framework Class Libraries 1.1
 * Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Web Edition

-



This article was previously published under Q321749



IN THIS TASK
SUMMARY
 * Sample Assembly Properties
 * Make an Assembly Available to ASP.NET Application
 * Register the Assembly in a ASP.NET Application Web Form



SUMMARY
This article provides step-by-step instructions to make and to register an assembly to be available in a WebForm to use with ASP.NET custom server controls.

back to the top

Sample Assembly Properties
To represent as a Custom Server Control, the assembly must have a class that directly or indirectly derives from System.Web.UI.Control and you must enclose the class in a namespace. The samples in this article are based on the assumption that the class is enclosed in the CustomControlNamespace namespace, and that the assembly was successfully compiled into a file named CustomControl.dll.

back to the top

Make an Assembly Available to ASP.NET Application
To make an assembly available for an ASP.NET application, you must place the assembly's .dll into the /bin folder of the application.  Navigate to the root directory of the application in Windows Explorer.

To find out what the application project folder is:  In the .NET environment, on the View menu, click Solution Explorer. Right-click a project main item in Solution Explorer, and then click Properties. In the Project Properties dialog box, click Common Properties, and then click General.

In the tree pane, you see the list with the Project Folder property. This is typically the root directory of the application.  In a Web Application project folder, create a folder that is named &quot;bin&quot; if no such folder exists. Copy or move the assembly's .dll into this folder.</li></ol>

You can now use the control from any ASP.NET page in your application's root directory (or any of its subfolders).

back to the top

Register the Assembly in an ASP.NET Application Web Form
In a .NET programming environment, open the Form .aspx source window, and then add the following tag to the top of the code <%@ Register TagPrefix=&quot;Custom&quot; Namespace=&quot;CustomControlNamespace&quot; Assembly= &quot;CustomControl&quot; %> where:
 * Custom is an alias that you associate with a namespace.
 * CustomControlNamespace is a namespace in which classes of an assembly are enclosed.
 * CustomControl is the name of the assembly file without an extension (.dll).

In your code, change these parameters to the appropriate names for your assembly.

Now the assembly is registered in a Web Form. You can use this registered assembly in your ASP.NET code with the chosen names. For example, the tag might be <Custom:CustomControl id=&quot;CustomControl1&quot; parameter1=&quot;value1&quot; parameter2=&quot;value2&quot; runat=&quot;server&quot;/> where Custom is the chosen name for the assembly's namespace, CustomControl is the custom server control name, and parameter1 and parameter2 are optional control properties that may vary based on your actual code.

back to the top

Keywords: kbhowtomaster KB321749

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.