Creating User Controls

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值