New Features in ASP.NET 2.0

Home arrow .NET Tutorials arrow ASP.NET arrow New Features in ASP.NET 2.0
New Features in ASP.NET 2.0 Print E-mail
Contributed by Howell   
Tuesday, 06 June 2006

ASP.NET 2.0 introduces a lot of new features. Some of these features aim to simplify the problems faced using the earlier versions and some features are introduced to provide lots of new facilities.

ASP.NET 2.0 aims to reduce the amount of code required to accomplish common Web programming tasks by 70 percent or more.

The most important features that are to be incorporated in ASP.NET 2.0 are:

1. Master Pages

Master Pages is supposed to remove one of the most important deficiencies of earlier versions of ASP.NET. Normally till now whenever a developer wants to replicate a common functionality of a web-page in other pages (basically use it as a template), the most possible option he uses is creating a user control and then replicate the functionality in other pages. It is very cumbersome. ASP.NET 2.0 aims to solve this problem by introducing the concept of Master Pages. First the developer needs to define a Master Page containing content that he wants to appear on other pages and then use ContentPlaceHolder controls to define the locations where sub pages can plug in content of their own. Then he has to build sub pages桝SPX files梩hat reference the master using directives like this one:
<%@ Page MasterPageFile="~/Trial.master" %>

In the sub pages, the developer has to use Content controls to fill in the placeholders in the Master Page.

In addition, an application can designate a default Master Page in Web.config, as shown here:
<configuration>
<system.web>
<pages masterPageFile="~/Trial.master" />
</system.web>
</configuration>


2. Data Source Controls

Data binding is even easier in ASP.NET 2.0, often requiring no code at all. There are a lot of new data source controls like: SqlDataSource, XmlDataSource, AccessDataSource etc to make the data binding much simpler.

For example suppose we want to bind a Student details table to a data grid in ASP.NET 2.0, then we just have to write the following few lines of code to do the job for us:
<html>
<body>
<form runat="server">
<asp:SqlDataSource ID="Students" RunAt="server"
ConnectionString="server=localhost;database=school;
SelectCommand="select roll_no, first_name, last_name, age, class from students" />
<asp:DataGrid DataSourceID="Students" RunAt="server" />
</form>
</body>
</html>

The SqlDataSource control defines the data source and the query performed on it, and the DataGrid's DataSourceID property points to the SqlDataSource. When the page loads, the SqlDataSource control performs the query and feeds the results to the DataGrid.


3. Themes and Skins

ASP.NET 2.0 introduces the concept of Themes and Skins by means of which the look and feel of the web pages can be enhanced to a great extent to make them visually catchy and attractive.

A skin is a set of visual attributes applied to a control type. A theme is a collection of skins. There are a lot of predefined themes in ASP.NET 2.0 and one can find them in subdirectories underneath Microsoft.NET\Framework\...\ ASP.NETClientFiles\Themes.
One can use it by using the following line of code:
<%@ Page Theme="SmokeAndGlass" %>
(SmokeAndGlass is one of the pre-defined themes).

The @ Page directive's new Theme attribute declaratively applies a theme to a page. Themes can also be applied programmatically using the Page class's Theme property. One can define themes and skins of his own and privately deploy them in subdirectories stemming from an application's Themes directory. Each subdirectory constitutes a theme, and the theme name equals the subdirectory name.

4. New Controls

There are around 50 new controls defined in ASP.NET 2.0. These new controls can be classified into the following groups:
?Mobile Controls
Pager - Partitions pages for rendering to small devices
PhoneLinks - Dials phone numbers on phone-enabled devices
?Rich Controls
TreeView - Renders hierarchical data as expandable/collapsible trees
Wizard - Guides users through step-wise procedures
?Login Controls
Login - Interface for logging in with user names and passwords
CreateUserWizard - Interface for creating new accounts
?Simple Controls
BulletedList - Displays bulleted lists of items
FileUpload - Permits files to be uploaded through Web pages
?Data source Controls
AccessDataSource - For data binding to Microsoft Access databases
XMLDataSource - For data binding to XML documents

5. Personalization

Personalization provides a ready-built solution to the problem of storing personalization settings for users of one's site. Currently, such settings are typically stored in cookies, back-end databases, or a combination of the two. It抯 cumbersome.

The ASP.NET 2.0 personalization service makes it easy to store per-user settings and retrieve them at will. It's based on user profiles, which you define in Web.config using the new <profile> element.

One can set the profile properties using the following piece of code:
<profile>
<properties>
<add name="UserName" Type="System.String" />
<add name="Password" Type="System.String" />
</properties>
</profile>

It defines 2 properties: UserName and Password. At run time, one can access these properties for the current user using the page's Profile property as follows:

String username = Profile.UserName;
String password = Profile.Password;

Similarly one can set back the profile properties as follows:

Profile.UserName = xyz?
Profile.Password = abc?


These are just few of the new features that we are going to see in the new version of ASP.NET. Hope in my next article, I will focus on the remaining features.

 


  home              contact us

 

©2006-2012 DeveloperZone.biz   All rights reserved     powered by Mambo Designed by Siteground