Creating User Controls

王朝asp·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

Creating User Controls

In addition to the built-in server controls in the .NET Framework, you can

also build your own controls to be placed on Web Forms. ASP.NET supports

two different types of user-created controls: user controls and custom

controls. The creation of custom controls is beyond the scope of this book,

but it's simple to create user controls. These controls are basically saved

pages (or pagelets) that act as self-contained controls.

For example, you may wish to create a menu system along the left side of

every page in your site, where each menu item is built from a database. You

might also want to place a standard logo and header on each page. What you

need is some way to include standard pages, or parts of pages, within each

of your pages.

User controls provide this functionality and are the replacement for

#include files in ASP.NET. Figure 6.4 displays the output you might want to

generate. In this example, the image and header "Northwind Traders" are

both in one user control. The menu going down the left side is another

control.

Figure 6.4. User controls output HTML on the client side.

Figure 6.5 shows the same Web page in design mode. As you can see, these

user controls are simply placeholders. You can see the full UI for such

controls by opening the file where you built them within your project.

Figure 6.5. User controls do not display any HTML on the server side; they

are just placeholders.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航