The one thing any development platform should do for you is
provide you with a solid foundation that you can build upon.
With ASP the foundation was good, but it was basically just a
pile of cinder blocks. With ASP.NET you get the foundation,
plumbing, heating, and electrical before you write your first
line of code! Many of the repetitive and annoying tasks that
you needed to do to build a good project are now done for you.
Object Oriented Model
To begin with, you now get a real event model and can control
when your code runs much better then ever before. It used to
be if you wanted something to run early, you put it near the
top of the page and if you wanted it to run later you put it
near the end. While this usually worked, it didn't make
very much sense and you often had to structure your code in
weird ways to obtain the desired effect. This "spaghetti-code"
problem can now be fixed by using a wide variety of events
such as Page_Load, which executes right before a page is loaded.
It doesn't stop with page level events either. Each object
on a page can have it's own event model and expose and raise
server events that can be programmed against and handled by
your script. Routines like Button_Click or Listbox_Change can
make doing standard form processing and much of your day-to-day
tasks relatively simple. Reading the code also become possible
so that when something goes wrong six months later, understanding
what you did and debugging your code is actually possible.
ASP.NET Server Controls
Well with everything being an object in the new world, there's
little wonder that ASP.NET provides some extremely useful ones built
right in. Many things that used to be components are now ASP.NET
Server Controls. For example the ad rotator has been updated
and now uses XML to store its information, but they didn't stop
there. There's a whole
set of controls that do everything from managing your form state
for you to displaying calendars and tables. In fact, for almost
every HTML element there's an ASP.NET Server Control that produces it
and allows you to interact with it programmatically. For instance
you no longer have to do a loop with a conditional to maintain a
selected option in a listbox. You can simply tell the listbox to
run at the server and to manage it for you. Better yet you can
programmatically tell the listbox which item to display as selected.
Perhaps one of the most interesting of these new controls is the
DataGrid. It's a multi-column data-bound grid that you can easily
place a data set into. It supports paging, sorting, and all the
cool stuff you would expect... and you don't have to write it all!
This sort of naturally leads us into what used to be called ADO...
ADO has been rewritten and is now ADO+
Let me just start this off right and scare you by saying recordsets
are gone! The new central object is the data set. It's basically
an in-memory copy of data and is similar to a recordset, but allows you
to do so much more. We'll cover this a lot in future articles
and code since it's sure to be the central point for much of your
development, but for now I'll just say that it's XML friendly, relatively
easy to use and helps unify and simplify things to make it easier for
you to get your work done. You can still do everything that you used
to... (except server-side cursors)... it's just a little bit different.
User Input Validation
Another extremely handy set of
ASP.NET Server Controls are the Validator controls. Think of all the code
you've written trying to validate user input. Now pretend that you had
a tool that made it all easier and left you just writing the conditions
the input should meet. Well that's basically what you've got and like
everything else they're event driven and can be accessed programmatically
or linked to other objects.
Once again we're back to caching!
It's basically what I've already said about everything else... the system
is in place, you just have to use it. You've been given the tools. Now
you just have to use them, not invent them.
(Have you figured out that I think this is really cool yet?!)