Datasheet

Customization themes override control definitions, thus changing the look and feel of controls.
Customization themes are applied with the
Theme attribute of the Page directive.
Stylesheet themes don’t override control definitions, thus allowing the control to use the theme
properties or override them. Stylesheet themes are applied with the
StylesheetTheme
attribute of the Page directive.
Now that you have an understanding of the concepts behind themes, the next section provides you with
a quick example of creating a theme and utilizing it from an ASP.NET page.
Creating a Simple Theme
To create a theme and apply it to a specific page, go through the following steps:
1. Create a folder called ControlThemes under the App_Themes folder.
2. Create a file with the extension .skin and add all the controls (that you want to use in a page) and
their style properties. Or you can also create individual skin files for each and every control. When
you are defining skin files, remember to remove the
ID attribute from all of the controls’ declara-
tions. For example, you can use the following code to define the theme for a
Button control:
<asp:Button runat=”server” BackColor=”Black” ForeColor=”White”
Font-Name=”Arial” Font-Size=”10px” />
3. Name the skin file Button.skin and place it under the ControlThemes folder. Once you have
created the
.skin file, you can then apply that theme to all the pages in your application by
using appropriate settings in the
Web.config file. To apply the theme to a specific page, all you
need to do is to add the
Theme attribute to the Page directive as shown below:
<%@Page Theme=”ControlThemes” %>
That’s all there is to creating a theme and utilizing it in an ASP.NET page. It is also possible for you to
programmatically access the theme associated with a specific page using the
Page.Theme property.
Similarly, you can also set the
SkinID property of any of the controls to specify the skin. If the theme
does not contain a
SkinID value for the control type, then no error is thrown and the control simply
defaults to its own properties. For dynamic controls, it is possible to set the
SkinID property after they
are created.
Web Parts Framework
There are many times when you would want to allow the users of your web site to be able to customize
the content by selecting, removing, and rearranging the contents in the web page. Traditionally, imple-
menting this capability required a lot of custom code, or you had to depend on third-party products to
accomplish this. To address this shortcoming, ASP.NET 2.0 ships with a Web Parts Framework that pro-
vides the infrastructure and the building blocks required for creating modular web pages that can be
easily customized by the users. You can use Web Parts to create portal pages that aggregate different
types of content, such as static text, links, and content that can change at runtime. It is also possible for
the users to change the layout of the Web Parts by dragging and dropping them from one place to
another, providing a rich user experience.
Web Parts are reusable pieces of code that allow you to logically group related func-
tionality together into one unit. Once the Web Parts are added to an ASP.NET page,
they can then be shown, hidden, moved around, and redesigned, all by the user.
13
Chapter 1: Introduction to ASP.NET 2.0
05_041796 ch01.qxp 12/29/06 9:09 PM Page 13