How to: Create ASP.NET User Controls
You create ASP.NET user controls in much the same way that you design ASP.NET Web pages. You can use the same HTML elements and controls on a user control that you do on a standard ASP.NET page. However, the user control does not have html, body, and form elements; and the file name extension must be .ascx.
To create an ASP.NET user control
Open the Web site project to which you want to add user controls. If you do not already have a Web site project, you can create one. For more information, see Local IIS Web Sites or How to: Create File System Web Sites.
On the Website menu, click Add New Item.
The Add New Item dialog box appears.
In the Add New Item dialog box, under Visual Studio installed templates, click Web User Control.
In the Name box, type a name for the control.
By default, the .ascx file name extension is appended to the control name that you type.
From the Language list, select the programming language that you want to use.
Optionally, if you want to keep any code for the user control in a separate file, select the Place code in separate file check box.
Click Add.
The new ASP.NET user control is created and then opened in the designer. The markup for this new control is similar to the markup for an ASP.NET Web page, except that it contains an @ Control directive instead of an @ Page directive, and the user control does not have html, body, and form elements.
Add any markup and controls to the new user control, and add code for any tasks that the user control will perform, such as handling control events or reading data from a data source.
See Also
Tasks
How to: Include ASP.NET User Controls in Web Pages