We create user controls much the same way that we create normal Web forms in ASP.NET; however, we normally denote that a file is to be used as a control by saving it with an .ascx file extension. Let's look at an example of a simple user control.
<asp:label text="Welcome to ASP.NET User Controls" runat="Server"/>
Yes, that's it. That's our entire control. Note that it's nothing more really than a Web form fragment, and in our control definition file we do not include <html>, <head>, <body>, or <form runat="server"> tags. Listing 9.1 shows how we use our control on a Web form.
<%@ Page language="c#"%> <%@ Register TagPrefix="ASPNETByExample" TagName="Welcome" ...