Wiley Professional Web Parts and Custom Controls with ASP.NET 2.0 978-0-7645-7860-1 ユーザーズマニュアル

製品コード
978-0-7645-7860-1
ページ / 20
Creating Your Own Controls
ASP.NET comes with its own set of server-side controls — so why create your own? And why
would you need three different kinds of controls: custom controls, Web Parts, and user controls? 
By creating your own controls, you can build powerful, reusable visual components for your 
Web application’s user interface, including components that allow your users to customize and
personalize your application. This chapter introduces you to the two primary types of controls
(custom controls and Web Parts) along with user controls. You’ll also see how creating your own
controls can simultaneously improve the quality of your Web applications, make you more pro-
ductive, and improve your user interfaces.
The Three Kinds of Controls
Why three different kinds of controls? Part of the reason is historical: Custom controls and user con-
trols were introduced in the first version of ASP.NET, while Web Parts are new to ASP.NET 2.0 and
add functionality that wasn’t available in user controls and custom controls. So, from one perspec-
tive, Web Parts are different from user controls and custom controls because they are “newer” — not
a very important difference. As you’ll see, Web Parts are really just an extension of custom controls,
but that new functionality provides developers with the opportunity to deliver something new: the
ability for users to customize Web pages. But even that description doesn’t really help distinguish
among the three types of controls: while Web Parts are a special class of control, you can use both
user controls and custom controls as Web parts (although they won’t have all the customization
facilities of a full-fledged Web Part).
Web Parts, custom controls, and user controls all allow you to create reusable components that can
be used, in turn, to create Web pages in ASP.NET. Web Parts, custom controls and user controls in
ASP.NET 2.0 look very much alike when you are using them to build Web pages. All can be used
in Design view, for instance — you can drag them onto a page, resize them, and set their properties
in the Property window. The major difference is that you drag custom controls and Web Parts from
the toolbox in Visual Studio .NET but you drag user controls from Solution Explorer. However, 
05_57860x ch01.qxd  10/4/05  9:26 PM  Page 3
COPYRIGHTED MATERIAL