User Control is often used in ASP. NET development. If many pages use the same User Control, each page must use <% @ Register ...... %> Introduce User Control before it can be used. This is very troublesome, so today we will teach you a simple method.
First Open web. config, and then add the following code to the <system. web> node (which can be modified as needed ):
Program code
<Pages>
<Controls>
<Add tagPrefix = "miles" src = "~ /Controls/Header. ascx "tagName =" header "/>
<Add tagPrefix = "miles" src = "~ /Controls/Footer. ascx "tagName =" footer "/>
</Controls>
</Pages>
After adding the file, you can use User Control on the page in the following way, eliminating the need to write <% @ Register ...... %>.
Program code
<Miles: header id = "Header" runat = "server"/>
<Miles: footer id = "Footer" runat = "server"/>
Note: This method is applicable only to version 2.0 or later.