ASP. NET User Control Tips 1

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.