I downloaded a source code from the internet yesterday and found that I don't understand one of them, that is, the custom control can be used directly without the register command and compiled normally. I also think this is good. Otherwise, a custom control is often used, and every page used must be referenced, which is very troublesome, but now the problem is that I don't know how he does it. Then I searched the control name segment in the project and found that there was a section in Web. config.CodeAfter referencing this, I searched the internet and found that the custom control can be registered in Web. config, and then it can be used directly, instead of using register every time.
This new function is introduced in ASP. NET 2.0, namely:
You only need to declare it once in the new pages-> controls section of the web. config file of your application:
<? XML version = "1.0"?>
<Configuration>
<System. Web>
<Pages>
<Controls>
<Add tagprefix = "scottgu" src = "~ /Controls/header. ascx "tagname =" Header "/>
<Add tagprefix = "scottgu" src = "~ /Controls/footer. ascx "tagname =" footer "/>
<Add tagprefix = "controlvendor" assembly = "controlvendorassembly"/>
</Controls>
</Pages>
</System. Web>
</Configuration>
("~" In ASP. NET The symbol means "locating from the application root path". It provides a good way to avoid using "..." everywhere in your code.)
Then I started the experiment immediately, and the result failed for the first time. I put the ascx control file and the ASPX page file in the same default directory, but when I build it, the system prompts that it seems impossible, then I move ascx to a new folder, and then in the web. the configuration is changed accordingly in config!