Register | Login 
View Article  

Current Articles | Categories | Search | Syndication

A look at the new features in ASP.Net 2.0

By Chad Bryant on Sunday, December 10, 2006 :: 7675 Views :: 1 Comments :: :: ASP.NET

ASP.Net was a radical change from its predecessor Active Server Pages (ASP) that represented an easy way to write dynamic pages prior to July 2000 when we saw the first introduction of Microsoft’s new .NET framework.  ASP was a great tool, but it was not an enterprise tool and it required the developer to write the code to handle just about everything.  ASP.Net was an incredible upgrade from a scripted non enterprise level programming tool to an object oriented enterprise level framework that made the life of web developers much easier by shielding the developer from the low level tasks of dealing with HTTP requests.  With ASP.Net came a powerful toolset that provided an event driven model of development (even if it was only an illusion) and a truly powerful framework of reusable objects that made web development very similar to the rapid application development environments that existed in the Windows development world.

 

So, with all the features provided in ASP.Net 1.x, did we really need another version?  How much better could it get?  Our development team in our company has only recently made the move from 1.x to 2.0 and I must emphatically state that yes, 2.0 is a much needed upgrade and only makes the life of developers even easier.

 

In this article I want to go over some of the new features specific to ASP.Net and just briefly give you an overview of each area so that you can see how ASP.Net 2.0 can make you a more productive and efficient developer of web applications!

 

The first area that I want to touch on is the goal of the ASP.Net development team at Microsoft to reduce the number of lines of code that a web developer has to write by 70%.  Wow, that is an ambitious goal indeed.  One of the new features of ASP.Net 2.0 that has made this possible is the introduction of declaratively binding your controls to a DataSource which encapsulates all the logic to handle retrieving data, updating data, etc from your database.  You don’t have to write code to bind to a control as this can be done declaratively in your html source in the aspx page.  Data binding cannot get any easier than that!  Some of the datasources provided are the SqlDatasource and the AccessDatasource for connecting to a SQL Server database or an Access database.  One of the Datasource components I was very glad to see was the ObjectDatasource.  When I first started to look at the Datasource controls in 2.0, I was a little concerned.  I did not want to have data access code and SQL Statements in my user interface layer.  I think most professional web applications are not developed this way.  Most professional web applications use an n-tier model with clear separation between the user interface layer, business logic layer, and data access layer.  The ObjectDatasource solves this problem nicely allowing me to encapsulate my database logic in a Datasource control that I could bind to, but still use middle tier custom objects to accomplish the work.  To give a simple example of the easier databinding model in 2.0 consider the following code which is self-explanatory and shows how we can bind the new GridView (a replacement for the DataGrid in 1.x) to a SqlDatasource declaratively with no code.

 

chad10.gif

 

This code will display a table of products from the Northwind database provided with SQL Server.  This would have required at least a little bit of code in 1.x and a lot of code prior to .NET!

 

The next feature in 2.0 that I would like to mention is the aspect of master pages.  Master pages make it easy to setup a template that our pages will follow to ensure a consistent look and feel throughout the site. Consider it like visual inheritance. Master pages make this very easy.  To use a master page you simply create a master page with a .master extension and put the common elements on the page that will be visible on every page in your site (or a specific group of pages in your site).  You setup ContentPlaceholder regions on the master page that act as placeholders for your page specific areas so that each page has its own region to merge in page specific content.  There are many great articles on the web that delve further into Master Pages, but I want to post the html code to link to a master page just to give you a quick view of how easy it is.  Consider the following code from an aspx page that uses a master page:

 

chad11.gif

 

We use the MasterPageFile attribute in the Page directive to link to the master page and then our content page has its content wrapped in a Content tag.  You do not put the html body, head, and other typical tags in your content page.  They are provided by the master page when your page and the master page are merged together.  Notice that our Content tag has a ContentPlaceHolderID attribute which allows us to link the content in the content tag into that specifc content region on the master page.  This model makes it a lot easier in 2.0 to provide a consistent look and feel throughout our site. 

 

Another great feature that I won’t really go into here because of the wealth of information available online is the topic of themes.  ASP.Net 2.0 allows you to setup themes which are contain skins, css classes, etc that you can assign to controls via a theme property and which aids in easily creating sites that not only provide a consistent look and feel, but also let you easily make changes to the look and feel after deployment.

 

The next area that I would like to address is the area of security.  ASP.Net has made it very easy to implement common security features in our site.  Let me briefly go over a few of these:

  1. A login control – this control provides functionality for logging into a site and validating a user against a database.  You can drop a login control on your page and very soon have a secure site complete with a login page that authenticates users against a database.
  2. A LoginStatus control – this control indicates the login status and provides login and logout links.
  3. A LoginName control – this control displays the name of the current logged in user (or anonymous).
  4. A CreateUser wizard to provide an easy and simple way to create user accounts.
  5. A PasswordRecovery control – this control provides the mechanism for users to click a link when they forget their password so that they can retrieve this information.

 

Along with these user interface controls, ASP.Net 2.0 provides the membership API that easily allows you to do things like Validate users attempting to login via the Membership.ValidateUser method.  However, if you use the login control it handles this for you and you don’t have to even write this code!  The 2.0 model is also extensible and you can plug in your own objects to handle the tasks that ASP.Net provides out of the box if you need custom functionality.

 

There are many other areas that I have not even touched on.  I simply wanted to provide a quick overview of the areas that interested me the most, but ASP.Net 2.0 provides so much more that would take several books to discuss properly. A few of these areas are personalization, easy creation of web portals with WebParts, better mobile control support,  a simpler way to add internationalization support to your applications, better web site administration options that alleviate the need to maintain your application settings directly in the web.config file, the ability to pre-compile your entire site before deployment which alleviates that first hit performance hit 1.x applications always suffered, and last but definitely not least is an improved intellisense model which is a welcome upgrade!

 

I have only begun to scratch the surface of all that ASP.Net 2.0 offers over the previous ASP.Net 1.x version.  Web applications are even easier to develop today and provide out of the box support for common features, but in an extensible way so that you can have complete control over how you want to accomplish a task.  There is a lot to learn in this new version, but promises to make the development of complex web applications even easier!  Have fun!






Chad Bryant is a senior developer with The Delta Group, a Greenville, SC based firm providing web based software to the healthcare industry. In addition to programming, Chad enjoys running marathons, spending time with his wife and three daughters, and reading books. Chad can be contacted via email at chadbryant5@charter.net

Previous Page | Next Page

COMMENTS

Good coverage of some of the high points of ASP.NET.

posted @ Sunday, December 10, 2006 7:24 PM by Joe Walling


Click here to post a comment

Copyright (c) 2010 GSP Developers
Walling Info Systems | Terms Of Use | Privacy Statement