الجمعة، 29 أبريل 2011

Themes and skins


Themes and skins


Building a professional web application involves much more than designing individual web pages. You also need the tools to integrate your web pages into a complete, unified website. ASP.NET offer new features that let you do that which called themes, themes let you define the formatting details for various controls and seamlessly reuse these formats in multiple pages. Themes make it much easier to standardize your website’s look and feel and tweak it later. Once a theme is in place, you can give your entire website a face-lift just by changing the theme definition

What is CSS

CSS stands for Cascading Style Sheets
Styles define how to display HTML elements
Styles were added to HTML 4.0 to solve a problem
External Style Sheets can save a lot of work
External Style Sheets are stored in CSS files

CSS Saves a Lot of Work
CSS defines HOW HTML elements are to be displayed.
Styles are normally saved in external .css files. External style sheets enable you to change the appearance and layout of all the pages in a Web site, just by editing one single file!
                               
Style Builder Dialog Box

The Style Builder dialog box provides options that make it possible for you to define cascading style sheet (CSS) style attributes. A CSS style combines individual formatting and positioning attributes into an attribute set that you can apply at the same time.

The Style Builder dialog box is divided into two panes. The left pane lists eight general categories (Font, Background, Text, Position, Layout, Edges, Lists, and Other). When you select a category, the right pane shows the options for the selected category. As you select style options, the Style Builder creates CSS style definitions for you.

You can apply the CSS style attributes directly to individual HTML elements on a single Web page, or you can add style attributes to CSS style rules stored on external style sheets. External style sheets can be used to define a common appearance for many Web pages at once.

Steps

With CSS, you use a stylesheet to define a set of formatting presets. You then link this stylesheet to the appropriate control using the CssClass property. To try it and add an (almost) empty stylesheet to your web project, choose Website ➤ Add New Item in Visual Studio. Then select Style Sheet, and click ok


To use a rule in a web page, you first need to link the page to the appropriate stylesheet. You do this by adding a tag in the section of your page. The tag references the file with the styles you want to use. Here’s an example that allows the page to use styles defined in the file
StyleSheet.css, assuming it’s in the same folder as the web page:

 Using ASP.NET 2.0 Skins

In order to see how to use one of these themes, create a basic page, which includes some text, a text box, a button, and a calendar.


You can instantly change the appearance of this page without changing the style of each server control on the page. From within the Page directive, you simply apply an ASP.NET theme that you have either built (shown later in this Model).

Adding the Theme attribute to the Page directive changes the appearance of everything on the page that is defined in an example SmokeAndGlass theme file. Using this theme, when I invoked the page in the browser, I got the result shown in Figure.

Applying a Theme to an Entire Application

In addition to applying an ASP.NET 2.0 theme to your ASP.NET pages using the Theme attribute within the Page directive, you can also apply it at an application level from the Web.config file.


If you specify the theme in the Web.config file, you don’t need to define the theme again in the Page directive of your ASP.NET pages. This theme is applied automatically to each and every page within your application.
Removing Themes from Server Controls

Whether themes are set at the application level or on a page, at times you want an alternative to the theme that has been defined. For example, change the text box server control that you have been working with (from Listing 9-1) by making its background black and using white text:

The black background color and the color of the text in the text box are specified directly in the control itself with the use of the BackColor and ForeColor attributes. If you have applied a theme to the page where this text box control is located, however, you won’t see this black background or white text because these changes are overridden by the theme itself.
To apply a theme to your ASP.NET page but not to this text box control, you simply use the

EnableTheming property of the text box server control:
BackColor=”#000000” ForeColor=”#ffffff” EnableTheming=”false” />

If you want to turn off theming for multiple controls within a page, consider using the Panel control to encapsulate a collection of controls and then set the EnableTheming attribute of the Panel control to False. This disables theming for each control contained within the Panel control.

Removing Themes from Web Pages
Now what if, when you set the theme for an entire application in the Web.config file, you want to exclude a single ASP.NET page? It is quite possible to remove a theme setting at the page level, just as
it is at the server control level.
The Page directive includes an EnableTheming attribute that can be used to remove theming from your ASP.NET pages. To remove the theme that would be applied by the theme setting in the Web.config, you simply construct your Page directive in the following manner:

This construct sets the theme to nothing—thereby removing any settings that were specified in the
Web.config file. When this directive is set to False at the page or control level, the Theme directory is not searched, and no .skin files are applied. When it is set to True at the page or control level, the
Theme directory is searched and .skin files are applied.
If themes are disabled because the EnableTheming attribute is set to False at the page level, you can still enable theming for specific controls on this page by setting the EnableTheming property for the control to True and applying a specific theme at the same time



Hosting Your Silverlight Application: Web Site or Web Application?


Hosting Your Silverlight Application: Web Site or Web Application?


In Visual Studio 2010, should you use a web site project or a web application project to host your Silverlight application? The main difference between a web site project and a Web Application project is how the files are compiled and deployed. Each has its advantages and disadvantages. In the end, the choice pretty much comes down to user preference. Let’s take a quick look at each approach.


Using a Visual Studio Web Site
A Visual Studio web site is nothing more than a group of files and folders in a folder. There is no project file. Instead, the site simply contains all the files under the specific folder, including all text files, images, and other file types.
A Visual Studio web site is compiled dynamically at runtime. An assembly will not be created, and you won’t have a bin directory.

The following are some advantages of using a Visual Studio web sit

• You don’t need a project file or virtual directory for the site.
• The site can easily be deployed or shared by simply copying the folder containing the site.


The following are some disadvantages of this approach

• There is no project file that you can double-click to open the site in Visual Studio.Rather, you must browse to the folder after opening Visual Studio.
• By default, all files within the site’s directory are included in the Web Site project.
If there are files within the site’s directory that you do not wish to be a part of the web site, you must rename the file, adding the extension .exclude.
Using a Visual Studio Web Application Project
A Visual Studio web application project is the more traditional type of web project used prior to Visual Studio 2005. When Microsoft developers introduced the “web site” concept, they did not take into account the many developers who were comfortable with the project-based solution approach. To accommodate those developers, Microsoft announced the Visual Studio 2005 Web Application project as an add-on to Visual Studio 2005. In Visual Studio 2008 and 2010, this project type is once again a part of Visual Studio.
The following are some of the advantages of using a Web Application project:
• All of the code files are compiled into a single assembly, placed in the bin directory.
• You can easily exclude files from a project, since all files within the project are defined within the project file.
• It’s easier to migrate from older versions of Visual Studio.
A disadvantage is that it can be more difficult to share your solution with others, if that is yourintent.
In the end, both approaches have their pros and cons. You need to determine which one is more suitable for your application, depending on your specific purpose and goals. For more information about these project types, refer to the MSDN documentation.

الثلاثاء، 26 أبريل 2011

Your Guide to Microsoft certification exams (2005 to 2010)