You are on page 1of 52

REFACTORING YOUR MSBUILD SCRIPTS p.

14
Presented by

THE WORLD’S LEADING .NET RESOURCE

2006 Volume 4 Issue7

AJAX-ifing your applications

AJAX, Java, Flash, and .NET


Rich Internet Application Market
Is It Really This Easy?
A day in the life of a developer

BizTalk Application Styles


����������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������
What can be done with Biztalk
����������������������������������������������������������������������������������������������

����������������������������������������
���������������������������������������
��������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������
��������������������������������������������������������������������������������������������

���������������������
Presorted PAGE 28 ������
Standard
US Postage �������������
PAID ������������
St. Croix Press ��������������

������������
������������
�������������

������
����������������
�����������

SANTA CLARA SILICON VALLEY ��������


Oct 3-4, 2006 • Santa Clara Convention Center � ������
� �����
� �����
� �������
W W W . D O T N E T D E V E L O P E��������������������������
R S J O U R N A L . C O M � ������
� �����
SUPERCHARGE
YOUR APPS WITH
THE POWER OF

LOCATION
INTELLIGENCE Enable Location Intelligent web services
Single environment for deployment
to desktop or web
Full integration with VisualStudio .NET

Create applications for:


• Web-based store/asset location finders • Visualizing where your customers are
• Analyzing where revenue comes from – and where it doesn’t • Managing assets such as cell towers, vehicles and ATMs

Try it and see for yourself. Visit www.mapinfo.com/sdk


Learn more about the MapInfo Location Platform for .NET,
access whitepapers and download free SDKs.

2 Contact usJulyat2006sales@mapinfo.com
Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com
Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 3
Inside DNDJ
EDITRIAL

Let’s Make This Easy


By Roger Strukhoff .................................................................................................... 7
BOOK REVIEW

Amazon.com Top 10 .NET Books


By Amazon.com ............................................................................................................. 8
SQL SERVER

DDL Triggers
By Jerry Dixon ................................................................................................................... 10
MSBUILD

Refactoring Your MSBuild Scripts


A Primer on Microsoft Atlas 14
By Tim Stall .........................................................................................................................
AJAX-ifying your applications
By Jeevan Murkoth 28 BOOK EXCERPT

Is It Really This Easy?


By Alex Homer and Dave Sussman ...................................................... 18
STYLES

BizTalk Application Styles


By Andy Morrison ........................................................................................................ 32
BOOK REVIEW

Pro ASP.NET 2.0 in C# 2005 and


Pro ASP.NET 2.0 in VB 2005
48
AJAX, Java, Flash, and .NET Reviewed by Dennis Hayes ............................................................................

Rich Internet applications market place MONKEY BUSINESS


By Coach K. Wei 38 Summer of Code Projects Announced
By Dennis Hayes .......................................................................................................... 50
4 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com
Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 5
��������������������������������������

������������������������������������

�������������������������������������
�������������������������������������������

������������������������������������������������������������������
��������������������������������������������
������������������������������������������������������������������

���������������������������������� ������������������������������
����������������������������������������������������������������������
������������������������������������������������������������������������
�������������������������������������������

��������������������������������������
4 ��������������������������������������������������������
����������������������������������������
4 ����������������������������������������������������������������
�����������������������������������������������������
���������������������������
4 ����������������������������������������������������������
�������������������������������������������������������� ��������������������������������������������
���������������������
4 ������������������������������������������������

����������������������������������������������������������������
������������������������������������ ��������������
���������������������
�������������

�������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
�����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������

6 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Editorial
Let’s Make This Easy
EDITORIAL BOARD
dotnetboard@sys-con.com
Editor-in-Chief
Derek Ferguson derekf@speakeasy.net
Group Publisher
Jeremy Geelan jeremy@sys-con.com By Roger Strukhoff
Mobility Editor
Jon Box jbox@psgi.net

E
Security Editor
Patrick Hynds phynds@criticalsites.com
“ ase-of-use” is one of those buzz terms that software
Open Source Editor
Dennis Hayes dennisdotnet@yahoo.com marketeers routinely inject into their promotional
Product Review Editor
Doug Holland doug.holland@precisionobjects.com
copy to describe their product. The term is one of
VB Editor those unarguable concepts; after all, who’s not in
Keith Franklin keithf@magenic.com
Smart Client Editor
favor of ease-of-use?
Tim Huckaby timh@interknowlogy.com Of course, the term is never qualified, quantified, or com-
BizTalk Editor
Brian Loesgen brian.loesgen@neudesic.com pared. We’re just supposed to nod our heads in acknowledg-
ADVISORY BOARD ment that the particular product being described is easy to
dotnetadvisors@sys-con.com use, and, implicitly, we’re supposed to be quite happy that
Derek Ferguson derekf@magenic.com
Jeremy Geelan jeremy@sys-con.com we’re not being saddled with one of those horrible products
Thom Robbins trobbins@microsoft.com
John Gomez John.Gomez@eclipsys.com that is difficult-to-use.
Scott Hanselman scott@hanselman.com The term, therefore, has little or no actual use. Universally
Dean Guida deang@infragistics.com
John Sharp johns@contentmaster.com deployed but rarely described, “ease-of-use” usually just takes
Jacob Cynamon jacobcy@microsoft.com
Chris Mayo cmayo@microsoft.com
up space in marketing brochures that could otherwise be
Gary Cornell gary@thecornells.com taken up by helpful terms such as “flexible,” “comprehensive,”
Joe Stagner joestag@microsoft.com
Peter DeBetta peter@debetta.com or “seamless interoperability.”
Executive Editor But the idea of software that is easy to use is an important
Nancy Valentine nancy@sys-con.com
Online Editor one, and one that is as important to developers as it is to end
Roger Strukhoff roger@sys-con.com users. This issue of .NET Developer’s Journal examines it in
Assistant Online Editor
Nicholas DeJesus nick@sys-con.com some detail in a number of articles.
SUBSCRIPTIONS Developers have long had tools, frameworks, and environ-
For subscriptions and requests for bulk orders, ments that are powerful. The past three decades of the IT
please send your letters to Subscription Department
Subscription Hotline: subscribe@sys-con.com industry have been characterized by software that continues
Cover Price: $6.99/issue
Domestic: $69.99/yr. (12 issues) to take advantage of, even push the limits of, the continuous
Canada/Mexico: $99.99/yr. Overseas: $129.99/yr. increase of computing power in a world driven by Moore’s
(u.s. banks or money orders). Back issues: $12/ea.,
plus shipping and handling. Law.
EDITORIAL OFFICES But much of the work is overly time-consuming, tedious,
SYS-CON Media 135 Chestnut Ridge Rd.,
Montvale, NJ 07645
and prone to a high number of errors. Making things easier
Telephone: 201 802-3000 Fax: 201 782-9638 for developers doesn’t create lazy developers, it creates better
.NET Developer’s Journal (issn#1541-2849) is
published monthly (12 times a year) for $69.99 by developers. It lets them design, test, and deploy things more
SYS-CON Publications, Inc.,135 Chestnut Ridge Road, quickly and efficiently. It lets them interact with a growing
Montvale, NJ 07645.
Postmaster: Send address changes to: welter of languages, approaches, and philosophies that show
.NET Developer’s Journal,
SYS-CON Publications, Inc., no signs of becoming less complex anytime soon.
135 Chestnut Ridge Road In this issue, whether you are reading about ASP 2.0, DDL,
Montvale, NJ 07645
Copyright © 2006 by SYS-CON Publications, Inc.
or Rich Internet Applications, you’ll see that theme of “ease”
All rights reserved. No part of this publication may be reproduced or
transmitted in any form or by any means, electronic or mechanical, recur repeatedly, as the best minds in the software business
including photocopy or any information storage and retrieval system,
without written permission. For promotional reprints, contact Reprint seek ever-better ways of handling routine tasks and complex About the Author...
Coordinator Dorothy Gil, dorothy@sys-con.com.
Worldwide Newsstand Distribution builds. Roger Strukhoff is West Coast Bureau
Curtis Circulation Company, New Milford, NJ
Newsstand Distribution Consultant:
The scripting revolution that is upon us adds both a new Chief for the SYS-CON News Desk, and
Gregory Associates / W.R.D.S.
732 607-9941 - BJGAssociates@cs.com thicket of complexity as well as shortcuts through it. The RIA/ President of www.wdva.com. He spent 15
For list rental information:
Kevin Collopy: 845 731-2684,
AJAX/Atlas revolution liberates all of us from a static Web 1.0 years with Miller Freeman Publications and
kevin.collopy@edithroman.com;
Frank Cipolla: 845 731-3832, world while emburdening developers with often-uncharted The International Data Group (IDG), then
frank.cipolla@epostdirect.com
challenges in creating the dynamic Web 2.0 world we all seem co-founded CoverOne Media, a custom
All brand and product names used on these pages are trade names,
service marks, or trademarks of their respective companies. SYS-CON
Publications, Inc., is not affiliated with the companies or products
to seek. Meanwhile, the present generation of developers publishing agency that he sold in 2004. His
covered in .NET Developer’s Journal. .NET and .NET-based marks are
trademarks or registered trademarks of Microsoft Corporation in the United struggles with moving data from platform to platform (seldom work has won awards from the American
States and other countries.
seamlessly), just as in the past. Business Media, Western Press Association,
SYS-CON Publications, Inc., reserves the right to revise, republish and
authorize its readers to use the articles submitted for publication. It will never be easy in any platonic description of this term. Illinois Press Association, and the Magazine
And “ease-of-use” will continue to be generic market fodder. Publishers Association. Read his blog at
Yet making things easier for developers remains a primary http://www.rssblog.Linux.SYS-CON.com.
goal for those who create development software. It is our hope Contact him at roger(at)sys-con.com.
that a readthrough of this issue of .NET Developer’s Journal
will make things just a little bit easier for you. roger@sys-con.com

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 7


Book Review

Amazon.com Top 10 .NET Books


President and CEO
MCSD .NET Programming
10 Solution
Architectures
4 Microsoft
Windows Ce .Net,
Fuat Kircaali fuat@sys-con.com

Group Publisher
Jeremy Geelan jeremy@sys-con.com
Exam Cram 2 Third Edition
(Exam 70-300) Boling, Douglas
ADVERTISING
Randy Cornish Senior Vice President, Sales and Marketing
Carmen Gonzalez carmen@sys-con.com
Programming Vice President, Sales and Marketing

9
Microsoft .NET
XML Web
3 Microsoft Visual
Basic .NET
Miles Silverman miles@sys-con.com
Advertising Director
Robyn Forma robyn@sys-con.com
Services Step by Version 2003 Advertising Sales Manager
Step (Book & CD- Megan Mussa megan@sys-con.com
Freeman, Adam ROM) Associate Sales Managers
Kerry Mealia kerry@sys-con.com
Balena, Francesco
Lauren Orsi lauren@sys-con.com

PRODUCTION
Programming MCAD/MCSD

8 .NET Web
Services
2 Training Guide
(70-315):
Lead Designer
Abraham Addo abraham@sys-con.com
Art Director
Alex Botero alex@sys-con.com
Ferrara, Alex Developing and
Associate Art Directors
Implementing Louis F. Cuffari louis@sys-con.com
Web Applications Video Editor
Ryan Palmieri ryan@sys-con.com
with Visual C# and Visual
Studio.NET
MCAD/MCSD Kalani, Amit WEB SERVICES
7 Self-Paced
Training Kit:
Information Systems Consultant
Robert Diamond robert@sys-con.com
Web Designers
Developing Stephen Kilmurray stephen@sys-con.com
Web Wayne Uffleman wayne@sys-con.com

Applications
with Microsoft Visual Basic .NET ACCOUNTING
and Microsoft Visual C# .NET, Financial Analyst
Joan LaRose joan@sys-con.com
Second Edition MCAD/MCSD Self-Paced
Accounts Payable
Microsoft Corporation Training Kit: Microsoft .NET Betty White betty@sys-con.com
Core Requirements, Exams Accounts Receivable
Gail Naples gailn@sys-con.com
70-305, 70-315, 70-306,

6
MCAD/MCSD
Training Guide
(70-320):
1 70-316, 70-310, 70-320,
and 70-300
Microsoft Corporation
SYS-CON EVENTS
President, Sys-con Events
Grisha Davida grisha@sys-con.com
Developing National Sales Manager
XML Web Jim Hanchrow jimh@sys-con.com
Services
and Server SUBSCRIPTIONS
Components with Visual C# 201 802-3012
.NET and the .NET Framework 888 303-5282
subscribe@sys-con.com
Amit Kalani

CUSTOMER RELATIONS
Circulation Service Coordinator
Test-Driven

5
Edna Earle Russell edna@sys-con.com
Development JDJ Store Manager
in Microsoft Brunilda Staropoli bruni@sys-con.com

.NET (Microsoft
Professional)
PROVIDED BY
Newkirk, James W.

8 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


BPEL is the
SQL of SOA

Get started building next-generation


SOA applications with the leading vendor of
BPEL technologies

Download BPEL tooling & server software today


������������������
activeBPEL
BPEL consulting, certification and training.
BPEL design tools, servers and source code for Eclipse, Apache Tomcat, JBoss,
WebSphere, WebLogic, BizTalk and Microsoft .NET.

Copyright 2006 Active Endpoints, Inc. All Rights Reserved.


All product names are trademarks or service marks of their respective companies.
Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 9
SQL Server

DDL Triggers
Monitor and control changes in SQL Server 2005
By Jerry Dixon

A
number of years ago, I worked for a com- to retrieve specific information about the event
pany that was developing internal applica- that caused the trigger to fire. Although a thorough
tions with SQL Server 2000. We didn’t have knowledge of XQuery isn’t critical, it’s definitely
any real database administrators. I was given that beneficial. You might want to refer to SQL Server
responsibility, but I was really a developer, one of Books Online for more information.
many in fact. The problem with this arrangement
was that all the developers had high-level rights Managing DDL Triggers
to SQL Server. Each one could make whatever DDL Triggers are managed in much the same
changes seemed appropriate to him at the time, way that DML Triggers are managed. You use
and they could do this without consulting me. the CREATE TRIGGER, ALTER TRIGGER, and
This often resulted in data incompatibilities that DROP TRIGGER statements. As you might expect,
caused a bit of downtime, but lots of irritation. however, there are subtle differences. The first
One day, however, my frustration reached a peak difference is scope. DML Triggers work against a
when some developer accidentally deleted a table particular table or view, but DDL Triggers work
that was used by a large number of applications. against a database or server. When managing DDL
No one would take responsibility for the dele- Triggers, you use the ON DATABASE clause or the
tion, and so, predictably, I was expected to find ON ALL SERVER clause to specify the scope. Next,
out who did it. I did manage to do it, but it took DDL Triggers fire in response to particular events or
a while and lots of SQL Profiler traces (I couldn’t groups of events. You use the FOR clause to specify
identify the culprit, so I had to catch him making them. Another important difference is that DDL
the same mistake again). I remember thinking, “I Triggers can’t be declared with the INSTEAD OF
wish I could easily prevent certain changes to the clause because these triggers can’t fire instead of
database, but allow others. I also wish I could log the indicated event like DML Triggers can. A final,
all the structure changes without having to resort but important, difference is that the ON DATABASE
to Profiler.” or ON ALL SERVER clause must be specified in
Today, my wish has been fulfilled. all CREATE TRIGGER, ALTER TRIGGER or DROP
SQL Server 2005 supports DDL Triggers. DDL Trig- TRIGGER statements. If you don’t specify one of
gers are triggers that fire in response to data defini- these clauses, SQL Server will assume that you are
About the Author tion language (DDL) statements such as CREATE referring to a DML Trigger instead of a DDL Trigger.
Jerry Dixon is a senior developer and archi- TABLE or UPDATE STATISTICS. They’re similar to Your statement will then fail to work properly.
tect for ACH Food Companies in Memphis, the data manipulation language (DML) triggers that Let’s walk though an example. In Listing 1 you
Tennessee. Over the past 16 years he has we’ve been using for years, except that they’re tied to can see the T-SQL code that creates a trigger that
led development projects for a number of a database or server instead of a table or view. With will fire in response to any DROP TABLE statement
enterprise, mid-level, and small business DDL Triggers we can write code that runs in response that is executed in the AdventureWorks data-
organizations. While he has fulfilled multiple to changes made to server and database objects. This base. The CREATE TRIGGER statement contains
roles as an infrastructure designer, database can be a very powerful tool. (It becomes even more the ON DATABASE clause, which indicates that
administrator, and software developer, he powerful when used with SQL Server’s CLR Integra- the scope of the trigger is the current database.
specializes in XML, SQL and ASP.NET. He tion feature, which allows SQL Server objects to be The FOR DROP_TABLE clause specifies that the
is a co-leader and frequent presenter at the created with our choice of .NET language.) DDL trigger should fire in response to a DROP TABLE
Memphis .NET User Group. Jerry holds the Triggers can be used for many purposes, but most statement. (See “DDL Events for Use with DDL
following Microsoft certifications: MCSD commonly for change tracking and prevention. Triggers” in the SQL Server 2005 Books Online for
(VB 6.0 and .NET), MCDBA (SQL 2000), This article introduces DDL Triggers and shows a list of available DDL events.) In the trigger body,
MCSA (Windows 2000 and 2003), MCSE how to use them to track and prevent changes to I’ve included a PRINT statement and a ROLLBACK
(Windows 2000), MCAD (.NET), MCT. He database objects. We’ll discuss trigger creation, TRANSACTION statement. This trigger will print
resides in Olive Branch, MS with his wife trigger deletion, and trigger security. We’ll also walk an explanatory message and then roll back the
and son. through some examples of typical DDL Trigger use. current transaction. This effectively “prevents” any
jdixon@achfood.com Along the way, we’ll see how we can use XQuery DROP TABLE statement from executing. Listing 1

10 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


SQL Server
also contains code to create and drop a test table.
Because of the trigger, the DROP TABLE statement
will fail, producing the output shown in Listing
2. (See Figure 1 for an example of the output pro- Figure 1: Drop table prevented
duced by a DROP TABLE command issued inside
SQL Server Management Studio.) Next, the code
drops the trigger (note the ON DATABASE clause)
and then successfully drops the test table.

Auditing Changes
The previous example “prevented” changes by roll-
ing back the transaction that caused them. While this
works well, it’s not always what’s needed. Sometimes
we want to allow changes, but we must have a record
of what changes were made and who made them. Figure 2: Audit table rows
DDL Triggers make this easy. In Listing 3, I’ve written
code that creates a trigger that records information a developer has permission to create and drop
about any change made to the AdventureWorks data- tables, why can’t he or she disable the database-
base. This code is more complex so let’s walk through scoped trigger before a change and re-enable it
it a little more slowly. First, I create a table to hold the afterwards? The answer is that different permis-
desired audit information. In this case, I want to know sions are needed for these actions. I can grant a
which command was executed by which user and at developer full rights to a database, but deny him or
what time. Next, I create the trigger. Once again, I use her the ALTER ANY DATABASE DDL TRIGGER per-
the ON DATABASE clause to specify the current data- mission. The developer will then be able to make
base as the trigger scope. Next, however, I use the ON practically any change to the database, but not be
DDL_DATABASE_LEVEL_EVENTS clause to specify able to affect the trigger that logs those changes.
that this trigger should fire in response to any change Similarly, managing server-scoped triggers requires
event in the entire database. (This demonstrates the the CONTROL SERVER permission. Users lacking
power of Event Groups. See “Event Groups for Use the proper permissions won’t be able to delete or
with DDL Triggers” in the SQL Server 2005 Books disable the DDL triggers.
Online for a list of available DDL event groups.) The
trigger body does three tasks. First, it uses the EVENT- Summary
DATA function to obtain an XML document that DDL Triggers bring a new level of control to SQL
contains information about the event that caused the Server 2005. They let code run when changes are
trigger to fire. The EVENTDATA function returns this made to database-level objects such as tables, roles,
data as an instance of the XML data type, and this or stored procedures. They also let code run when
data is stored in the @Data variable. Next, the QUERY changes are made to server-level objects such as
method is used to get specific pieces of information logins, endpoints, and databases. The triggers can
from the XML document stored in the @Data vari- perform actions ranging from change
able. (The QUERY method is one of the five meth- prevention (ROLLBACK TRANSAC-
ods provided by the XML data type. This particular TION) to change auditing (storing
method accepts an XQuery query string, and returns change information in a table) and
an instance of the XML data type.) This process is notification (sending an e-mail to the
repeated twice; once to get the text of the executed DBA when a change is made). In ad-
command (//TSQLCommand/CommandText), dition, because DDL Trigger manage-
and once to get the time when the command was ment requires its own set of permis-
executed (//PostTime). The standard SYSTEM_USER sions, developers with high-level
function provides the name of the user who invoked rights can be prevented from deleting
the command. Finally, the collected information in or overriding the triggers.
inserted into the DDLAudit table. To return to my story. If DDL
The rest of the code in Listing 3 tests the trigger. A Triggers had been available in SQL
test table is created and dropped and then the con- Server 2000, I could have implemented a trigger
tents of the DDLAudit table are shown. See Figure 2 that would have stopped the developer from delet-
for the results. You can see the commands that were ing that important table. The trigger could also
executed, the user who executed the commands, have logged the attempt and maybe even notified
and the time when the commands were executed. me straightaway. We would have saved time, data,
and a lot of frustration. You can bet that I’ll be
Permissions implementing DDL triggers in my next enterprise
You may be wondering how all of this helps. If database.

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 11


SQL Server

LISTING 1 – SIMPLE TRIGGER DECLARE @PostUser NVARCHAR(100)


USE AdventureWorks DECLARE @TempXML XML
GO
SET @Data = EVENTDATA()
-- create a database DDL trigger
CREATE TRIGGER trgDropTable -- use XQuery to extract command name
ON DATABASE SET @TempXML =
FOR DROP_TABLE @data.query(
AS ’data(//TSQLCommand/CommandText)’)
PRINT ‘Table deletion is not allowed.’
ROLLBACK TRANSACTION SET @Command =
GO CONVERT(NVARCHAR(100), @TempXML)

-- create a test table -- use XQuery to extract post time


CREATE TABLE Test(ColA INT) SET @TempXML =
GO @data.query(’data(//PostTime)’)

-- attempt to drop the test table SET @PostTime =


-- this will fail CONVERT(NVARCHAR(24), @TempXML)
DROP TABLE TEST
GO SET @PostUser = SYSTEM_USER

-- drop the trigger INSERT INTO DDLAudit


DROP TRIGGER trgDropTable ON DATABASE (
GO Command
,PostUser
-- attempt to drop the test table ,PostTime
-- this will now succeed )
DROP TABLE TEST VALUES
GO (
@Command
LISTING 2 – DROP TABLE PREVENTED ,@PostUser
Table deletion is not allowed. ,@PostTime
Msg 3609, Level 16, State 2, Line 1 )
The transaction ended in the trigger. GO
The batch has been aborted.
-- create a test table
Listing 3 – Auditing DDL Events CREATE TABLE Test(ColA INT)
USE AdventureWorks GO
GO
-- drop the test table
-- create an audit table DROP TABLE TEST
CREATE TABLE DDLAudit GO
(
Command NVARCHAR(1000) -- review rows in audit table
,PostUser NVARCHAR(100) SELECT * FROM DDLAudit
,PostTime NVARCHAR(24) GO
)
GO -- drop the trigger
DROP TRIGGER trgDDLAudit ON DATABASE
-- create a database DDL trigger GO
CREATE TRIGGER trgDDLAudit
ON DATABASE -- drop the table
FOR DDL_DATABASE_LEVEL_EVENTS DROP TABLE DDLAudit
AS GO
DECLARE @Data XML
DECLARE @Command NVARCHAR(1000)
DECLARE @PostTime NVARCHAR(24)

12 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 13
MSBuild

Refactoring Your MSBuild Scripts


How to make maintainable processes
By Tim Stall

S
ome things change how you fundamentally <Message Text=”This is a task, print $(Var2)”
program. Automation is one of those things. />
It is what will save you from wasting your <Copy SourceFiles=”$(root)\abc.txt”
weekend stepping through tedious and error-prone DestinationFolder=”$(root)\myFolder” />
processes like regression testing (unit, integration, </Target>
performance, functional, etc.), builds, deployment,
or even documentation. Automation is one of those The rest of this article will focus on the remain-
buzzwords we all know our projects should have ing three steps.
(like “performance,” “security,” “maintainability,”
etc…), but the question is how? Splitting Out Scripts
Microsoft gave us a huge answer with .NET 2.0’s Each MSBuild script is called a “project file.”
MSBuild – its new build platform with a process- The extensions doesn’t really matter, but will often
oriented scripting language. It can revolutionize not be *.msbuild, *.task, or *.proj. Each project file
just how you build, but also how you test, deploy, and is enclosed in the <Project> node (to save space,
automate many of your development processes. The we’ll omit the project node in the code snippets).
problem with these scripts, like the problem with MSBuild provides two ways to reach across physi-
anything else, is that they must be maintained. Per- cally separate projects files: (1) the Import Element
haps the best way to maintain them is to keep them and (2) the MSBuild task (not to be confused with
refactored – something that MSBuild makes very easy. MSBuild the engine itself).
The Import element lets you insert one project
MSBuild Background file into another. For example, suppose you had a
Refactoring is improving the code (usually by bunch of system-wide variables like application in-
eliminating redundancy) while keeping the same stall paths. Getting a new version of an application
functionality. To eliminate redundancy, you have may require updating its path, so you want to store
to be able to split out code into separate, reusable all paths in a single file so it can be updated just
chunks, and then pass data between those chunks. once. You could do this by putting those paths in
A simple MSBuild script is just a series of tasks. their own project (like “CommonProperties.proj”),
Therefore refactoring requires these steps: and then importing that project into any script that
1. Pull out reusable properties. needed it. This lets you update variables without
2. Group multiple tasks into a single target. touching each script.
3. Split out these targets into physically
separate files CommonProperties.proj
4. Call these targets as needed. <PropertyGroup>
5. Pass data to and from these targets as we <NameA>Value1</NameA>
call them. <NameB>Value2</NameB>
</PropertyGroup>
The first two steps are trivial. For example, this
snippet shows two tasks (Message and Copy) Some other script:
grouped into a single target with variables named <Import Project=”CommonProperties.proj” />
Var1 and Var2. Note that you can use one variable <PropertyGroup>
in defining another. <NameB>Overrided</NameB>
<NameC>Value3</NameC>
<PropertyGroup> </PropertyGroup>
<Var1>abc</Var1>
About the Author <Var2>$(abc)def</Var2> <Target Name=”EndPoint”>
Tim Stall is a software developer at <root>C:\myProj</root> <Message Text=”value from Include: $(NameA)”
Paylocity, an independent provider of </PropertyGroup> />
payroll and human resource solutions. <Message Text=”value from Include: $(NameB)”
tims@paylocity.com <Target Name=”EndPoint”> />

14 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


MSBuild
</Target> le”>
</Target>
Note that the properties in the imported script
get overridden by any properties of the same name MSBuild is also smart enough to call each de-
in the parent script. pendency only once. So if we added the GetSource
Besides importing an entire project file, you can target to the last line, so that it appears twice, it
split your targets into separate project files and call would still be called just once:
them with the MSBuild task. The purpose of the
MSBuild task is to call other targets, so we’ll explain <Target Name=”UnitTest” DependsOnTargets=”Compil
it more in our next section. e;GetSource”>

Ways to Call Targets Note that using CallTarget is an explicit approach


Once we have separate files, we have to be able – you start at the first target and march forward,
to call targets in those files. MSBuild provides at explicitly calling each target in the order you want.
least three ways to do this: (1) The MSBuild task On the contrary, DependsOnTargets is an implicit
that we just talked about, (2) The CallTarget task, approach – MSBuild starts at the end of your script
and (3) the DependsOnTargets attribute of a target. and steps backwards to infer the calling order.
The MSBuild task is a powerful way to call targets.
Because Visual Studio 2005 csproj projects are Getting and Setting Properties
actually just MSBuild scripts, most developers are Once you split out your MSBuild script into sepa-
already using the MSBuild task. For example, these rate files and can call targets in those files, you’ll soon
lines would build the MyApp project: find yourself wanting to pass data to those targets. For
example, you may write a task that drops a database,
<MSBuild Projects=”$(rootdir)\MyApp.csproj” but you’ll want to be able to specify which database
Targets=”rebuild” Properties=”Configuration= to drop. Any external data source, such as database
release” /> connection strings, ftp addresses, file paths, output
product names, etc., should each be abstracted to a
This task has three main attributes: the physical single property. The last thing you want to do is waste
Project(s) file, the Target(s) to call within that project, time searching your script to change every instance
and finally any Property(or Properties) to pass to of a file path from “C:\something” to “D:\something.”
that target. The power of the MSBuild task is that you You may also consider abstracting strategy decisions
can call any MSBuild project file and pass in your to properties – should this check local or network
own properties (we’ll discuss this more in the next resources, should this copy the output products to
section). This essentially lets you abstract out your destination X or not, etc,? You could then reference
targets to separate files as if they were class libraries. these properties in the conditional attribute available
When you don’t need the full power of the MS-
Build task, you can use the CallTarget task. Unlike Technique Description Useful for
the MSBuild task, it requires that the target be in Imports Physically dump the Storing common tasks or properties in a physically sepa-
the current project file (including all imported contents of one script into rate script and then including it in other scripts.
files), and it doesn’t let you pass in your own another.
property values. For example, you may have a build Separate MSBuild project A physically separate This technique lets you create class libraries of MSBuild
script that calls certain targets in a specific order: MSBuild file. tasks, and you can then call those tasks with the MSBuild
target, passing in parameters.
<CallTarget Targets=”GetSource” />
<CallTarget Targets=”Compile” /> Note that all VS Projects are already separate MSBuild
projects.
<CallTarget Targets=”UnitTest” />
Table 1: Ways to split out MSBuild files
Yet another way to call targets is by using the
“DependsOnTargets” attribute to specify which Technique Description Useful for
other targets the current target depends on. MS- <CallTarget> task A task that calls other targets in the Calling targets in the current file that use the same global
Build is smart enough to automatically order the current project file. properties.
targets by their dependencies. Explicit ordering: List the targets in the order you explicitly
want them called.

<Target Name=”GetSource”> DependsOnTargets An attribute of a target that lists Ensuring that targets are called as they are needed.
</Target> attribute which targets must be run before Implicit ordering: MSBuild steps backwards through your
the current target is run. script to infer the calling order.
<Target Name=”Compile” DependsOnTargets=”GetSou
rce”> <MSBuild> task A task that calls other targets in any Calling targets in any file with the ability to pass in
project file. properties.
</Target>
<Target Name=”UnitTest” DependsOnTargets=”Compi Table 2: Three different ways to call Targets

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 15


MSBuild

to all targets and tasks, giving your script immediate builds. This task is also faster because no new
flexibility. MSBuild process is created.”
MSBuild offers at least five ways to get and set
properties. <MSBuild Projects=”CommonTasks.proj”
Targets=”TestOutput” Properties=”Var1=xyz;Var2=ab
1. PropertyGroup: The easiest way to set properties c” />
is with a PropertyGroup, as we discussed earlier.
Any property specified in this group is global for 4. Output: Tasks can have output values. For ex-
the entire project script. ample, an executable has a return code. You can
get that value and store it in a local property via
<PropertyGroup> the task’s <Output> inner property. In the snip-
<ApplicationPath>c:\myproj\stuff.exe</Applica- pet below we run an exe that creates a random
tionPath> number and saves it to the property “NumberA.”
<UseLocalOptions>Value3</UseLocalOptions> This property need not exist in a global Proper-
</PropertyGroup> tyGroup list, but if it does then the local value
will overwrite the global one for the scope of the
2. MSBuild.exe: You can also pass in values through target. Once control leaves the target the newly
the command line using MSBuild.exe (the execut- created property is lost.
able engine, not the task) and the “/p” switch. You
can set multiple properties by separating them with <Target Name=”EndPoint”>
semicolons. Any property set here overrides what <Exec IgnoreExitCode=”true”
may be in the propertyGroup section. Command=”GetRandomNumber.exe”>
<Output TaskParameter=”ExitCode”
MSBuild.exe CommandLine.msbuild /p: PropertyName=”NumberA”/>
Var1=AAA;Var2=BBB </Exec>
<Message Text=”Output value is ‘$(NumberA)’”
You can combine these two techniques />
to make your scripts much more maintainable. </Target>
For example, you could first abstract all directory
information to their own properties, and then 5. CreateProperty Task: Sometimes you just want
have different bat files pass in different directo- to create a temporary local variable. You can use
ries (as property values) to the same script. This the CreatePropertyTask and its Output value to
would let you use the same MSBuild script for do just that. The following snippet shows how to
multiple directories. create a local variable “MyLocalProp.”

3. MSBuild Task: We’ve already mentioned our <PropertyGroup>


third way to pass properties – using the MSBuild <Var1>Value1</Var1>
task. This is similar to the command line in that </PropertyGroup>
you also pass values through a semicolon-sepa-
rated list, and those values have a global scope <Target Name=”EndPoint”>
in the target being called. However, the task <CreateProperty Value=”Prop_$(Var1)_val”>
and command=line calls are different, as best <Output
explained by the MSDN Help: “Unlike using the TaskParameter=”Value”
Exec Task to invoke MSBuild.exe, this task uses PropertyName=”MyLocalProp” />
the same MSBuild process to build the child </CreateProperty>
projects. The list of already-built targets that can
be skipped is shared between the parent and child <Message Text=”New value: $(MyLocalProp)” />
</Target>
Technique Scope Useful for
<PropertyGroup> Global Set for Current Target Simple. Can be overridden via command line or MSBuild task. These five different ways to set properties offer
much flexibility.
Via Command Line Global Set for Project Calling from batch, global, not changing MSBuild script.
Pass through the Global Set for Child Project Sending values into a child target. The values will be global
Conclusion
MSBuild task for that target.
MSBuild scripts can automate many of the most
Task’s <Output> Local Get for Target Get output value from Task, such as a console app’s return
tedious and boring parts of your project, so it’s a
code.
good investment to learn how they work. Knowing
<CreateProperty> Local Create (and Set) for Current Creating a local property within a target temporarily overriding how to split your scripts into separate files and then
Target a global property within the scope of the target.
call any target with any properties lets you refactor
Table 3: Five ways to set properties those scripts, making it even better.

16 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 17
Book Excerpt

Is It Really This Easy?


A day in the life of a developer
By Alex Homer and Dave Sussman

A
SP.NET 2.0 contains a raft of new features Using a Data Source Control and
that reduce the code you need to write and GridView to Display Data
save you time and effort when building dy- To build almost all types of data access pages,
namic and interactive Web pages and applications. you need to be able to get the data from the
To illustrate this, and so that you get a better database and display it in a Web page. In previous
feel for the way all these features combine versions of ASP and ASP.NET, you would already
to provide the overall ASP.NET 2.0 develop- be thinking about creating a connection to the
ment experience, this excerpt presents a database, building a Recordset or filling a DataSet,
scenario-based demonstration focused on and then either iterating through the rows to create
a day in the life of a developer who is in the an HTML table (in ASP 3.0) or taking advantage of
process of fulfilling the requirements of server-side data binding in ASP.NET 1.x. However,
a fictional customer. Although this may in ASP.NET 2.0, the process is much easier. You start
seem a contrived approach, it actually by using the Server Explorer window (or the Data-
follows the general process of evolving base Explorer window in Visual Web Developer) to
your applications to meet the needs of create a connection to the database (see Figure 1).
the users. More than that, it shows you Now that you have access to the database, you
how all the various features in ASP. need a new Web page. This will be part of the exist-
NET 2.0 fit together and interact to ing AdventureWorks Web site that you have already
give you improved productivity and a built, and so you must first open this site. Visual
simpler development process. Along Studio 2005 and Visual Web Developer allow you to
the way, you will see the process steps open an existing site using a range of techniques,
required for: including directly from the file system, from the
• Using a data source control and GridView to local IIS folders via HTTP, or from a remote site via
display data FTP or the Microsoft FrontPage Extensions (see
• Enabling sorting and paging for the rows Figure 2). Next, you create a new Web Form, switch
• Providing a row editing feature to Design view, and drag the Product table from
• Adding filtering to select specific sets of rows the Server/Database Explorer window onto the
• Displaying single rows in a form for editing new Web Form. This adds a SqlDataSource and a
• Working with data exposed through a business GridView control to the page and you can run the
object page to see the results. Okay, so it isn’t very pretty
• Caching the data to reduce database access and probably contains columns that you don’t want
• Using a master page to give a consistent look and to display, but it really does save you time in getting
feel the basics of the page up and running––and you
• Adding a menu and other navigation features haven’t written any code at all! (see Figure 3).
About the Authors You can now fine-tune the page to provide
Alex Homer is a computer geek and Web By the end of this excerpt, you will have a good just the features you want by removing columns,
developer with a passion for ASP.NET, who understanding of the main features in ASP.NET 2.0 adding formatting to the values, and applying
doubles as a consultant, trainer, and speaker. that make your life as a developer much easier. one of the predefined (Auto Format) styles to the
It’s nine-thirty in the morning, and your second GridView. The Visual Studio 2005 and Visual Web
Dave Sussman speaks frequently at Micro- cup of coffee is just starting to take effect when Developer page designers provide a “tasks” pane
soft development conferences and has been the phone rings. At the other end is Margaret, the for many of the rich controls such as the GridView
writing about ASP since its earliest release. CEO of AdventureWorks Trading Inc., and she is that makes it easy to complete all these tasks. The
in no mood for light conversation. It seems that, tasks pane appears when you first add a control to
Together, Dave and Al have written many although they love the new Web site you created for the page. You can also open it by clicking the small
books on Microsoft technologies, including them, they just discovered that there is no page for arrow icon that appears when you move the mouse
ASP.NET v. 2.0 - The Beta Version (Ad- their staff to view lists of products. So you commit over the control (see Figure 4).
dison-Wesley, 2005). They are the only two to provide one, drain the remnants of the now cold The tasks panes contain a set of links that open
Microsoft “Software Legends’ from the UK. coffee, and fire up Visual Studio 2005. dialogs or start Wizards, depending on the control

18 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Book Excerpt
type. For the GridView control, as you can see in just select the Enable Editing and Enable Deleting
Figure 4, the tasks include applying an Auto For- options in the tasks pane for the GridView control.
mat, selecting the appropriate data source control, You will see the Edit and Delete links appear at the
enabling various features directly supported by the left-hand side of the grid (see Figure 8). Now users
new GridView control in ASP.NET 2.0, and modify- can edit any of the column values in individual
ing the columns displayed by the GridView control. rows (except for the primary key column) and per-
You only want to display the six most useful sist these changes back to the database while you
columns, so you can remove the rest from the list. still have not written a single line of code!
Moreover, you want the StandardCost and ListPrice
columns to display as currency values, so you can Adding Filtering to Select
specify this in the DataFormatString property for Specific Sets of Rows
these columns (see Figure 5). Just when you think you’ve satisfied Margaret the
CEO at AdventureWorks Trading Inc. with a shiny
Enabling Sorting and Paging
for the Rows
The GridView control now displays the required
columns from the database table, but it is not very
easy for the user to find the rows they want to
view. All the rows appear in one long list sorted by
product number. It would be helpful if users could
sort the rows in a different order (perhaps by name
when they don’t know the product number), and it
would also be nice to be able to limit the display to
a specific number of rows and provide navigation
controls so that they can see separate “pages” of
rows.
Prior to ASP.NET 2.0, you would now be writing
code to sort the source rowset into the required or-
der, and then connecting this code up to controls in
the page. In ASP.NET 2.0, it is all automatic. You just
turn on sorting and paging with the checkboxes in
the tasks pane (see Figure 6). The column headings
become hyperlinks, and the paging controls appear
at the foot of the grid. Then you can make the page
look nicer by selecting an appropriate Auto Format
option from the list that appears when you click Figure 1: Connecting to a database
the link in the tasks pane, and the page is complete
(see Figure 7). You run the page to see the results.
Clicking any one of the column heading hyperlinks
sorts the rows in ascending order by that column
value. Another click on the heading changes the
sort order to descending. You’ve created an ex-
tremely useful and usable page, and you have not
written any code at all.

Providing a Row Editing Feature


While you have the tasks pane open for the
GridView control, you might as well take advantage
of some of the other features it offers. How about
allowing users to edit the rows? This used to involve
a lot of work writing code to handle the edit/up-
date/cancel options that are part of the process
for editing rows in a Web page, even in ASP.NET
1.x, and you still had to figure out how to push the
changes back into the database by executing SQL
UPDATE statements.
In ASP.NET 2.0, all of this goes away if you are
happy to use the default parameterized SQL state-
ment approach to updating the database table. You Figure 2: Opening an existing Web site

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 19


Book Excerpt

new Web page for displaying product informa- the database rows in the Products table. Therefore,
tion, the phone rings again. It’s Mike, the Adven- step one is to drag another SqlDataSource control
tureWorks sales manager, who says that his sales onto the page and click the Configure Data Source
people from different divisions of the company will link in the tasks pane to start the Configure Data
want to be able to filter the list by category, rather Source Wizard.
than just getting a list of all of the products. He The first page of the Wizard specifies the con-
would also like this implemented as soon as pos- nection string to use (you select the same one that
sible. was created for the previous SqlDataSource control
Thoughts of a nice long lunch break evaporate, from the list), and then you can specify the query to
and back you go to Visual Studio. You will need select the rows for the database. The table named
some kind of control where users can select the ProductSubcategory contains the ID and name of
category they want to view, and the obvious one is each category for the items in the Products table.
a drop-down list box (a DropDownList control). You Now you can drag that DropDownList control
will also need some way of populating this drop- onto the page and select the new SqlDataSource
down list with the available categories, taken from control as the source of the data. You specify that
the DropDownList will show the name of the
subcategory, while the value of each item in the list
will be the ProductSubcategoryID. Also, make sure
you set AutoPostback to True (in the tasks pane) so
that changes to the selected value will submit the
page to the server. Run the page, and you see a list
of the categories. All of the list controls that sup-
port server-side data binding can be used with a
data source control in this way, even controls such
as the DropDownList that were originally provided
with ASP.NET version 1.x.
All that remains is to connect the DropDownList
and the GridView together so that the GridView
displays rows from the category selected in the
DropDownList. How much code do you need
to write for this? Perhaps you can guess that the
answer is (still) none. Select the SqlDataSource
control that powers the GridView control and run
the Configure Data Source Wizard again by select-
Figure 3: Creating a data display page with drag and drop in Visual Studio 2005 ing this option in the tasks pane.
In the second page of the Wizard, click the
WHERE button to open the Add WHERE Clause
dialog. Here you specify the column to which the
condition will apply, the comparison operator,
and the source of the value to compare against
the column value. This value is, of course, the
value currently selected in the DropDownList
control, and the dialog shows the SQL expression
that will be added as the WHERE clause next to
the Add button. This adds a WHERE clause to the
SQL statement that includes a parameter for the
category, and adds a ControlParameter to the
declaration of the SqlDataSource control. If you
switch to Source view in Visual Studio 2005 or
Visual Web Developer, you will see the code for
the SqlDataSource control with this ControlPa-
rameter element nested in the SelectParameters
section (see Listing 1).
Now, as the page posts back each time the user
makes a selection in the DropDownList, the origi-
nal SqlDataSource control populates the parameter
in the SQL statement with the SelectedValue prop-
erty of the DropDownList, so that the GridView
Figure 4: Opening the tasks pane in Visual Studio and Visual Web Developer displays only rows from the selected category.

20 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


XML’s Endless Possibilities,

None of the Risk.

Forum XWall™ Web Services Firewall - Reinventing Security

Security should never be an inhibitor to new opportunity: Forum XWall™ Web Services
Firewall has been enabling Fortune 1000 companies to move forward with XML Web
services confidently. Forum XWall regulates the flow of XML data, prevents unwanted
intrusions and controls access to critical Web services.

Visit us at www.forumsys.com to learn more about how you can take your next leap
forward without increasing the risks to your business.

fo r u m syst e m s ™ – t h e l e a d e r i n we b s e rv i c e s s ec u r i t y ™

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 21


Book Excerpt

Displaying Single Rows in a checkboxes in the tasks pane for the GridView
Form for Editing control.
The page now displays the rows from the da- Now you drag another SqlDataSource control
tabase table, allows them to be sorted in almost onto the page and click the Configure Data Source
any order, and displays them in separate pages. link in the tasks pane to start the Wizard. In the
It also allows filtering by product category to be first page, you select the same connection string
applied to the rows, and editing to be performed as before. In the second page of the Wizard, you
on all but the primary key column. However, this specify that the query should include all except for
editing feature is not the most ideal of approach- the last two columns from the Product table. Then
es, and it is not as intuitive as the traditional click the WHEREbutton to add a ControlParameter
approach for editing the values in one row in a to the SqlDataSource control just as you did in the
separate “form”-style page. previous section. However, this time, specify the
In ASP.NET 2.0, you can take advantage of a new SelectedValue property of the Grid- View control
control named DetailsView that provides a “one so that – following a postback – this third SqlData-
page at a time” view of the rows exposed by a data Source control will expose only the row selected in
source control. Moreover, you can connect the the GridView control.
GridView and DetailsView controls together so that By default, the SqlDataSource does not provide
viewing rows is easy in the grid, while editing is for editing of rows. It only did so for the SqlData-
more intuitive in the “form” view. Source that powers the main GridView control be-
The first step in this process is to turn off editing cause you created this by dragging a table from the
in the GridView, and enable selection so that users Server/Database Explorer window onto the page.
can select a row in the GridView control. Both of When you add a SqlDataSource to a page from the
these tasks are performed simply by setting the Toolbox, you must specify if you want to be able to
update the rows (in most cases you will not, and so
this default makes sense). You therefore remember
to click the Advanced button in the second page of
the Wizard and tick the options in the dialog that
appears. Next, drag a DetailsView control onto the
page and bind it to the new SqlDataSource control
using the drop-down Choose Data Source list in the
tasks pane. While you are there, use the options in
the tasks pane for the DetailsView control to apply
the same Auto Format as before, and turn on En-
able Inserting, Enable Editing, and EnableDeleting.
You then see the Edit, Delete, and New links appear
at the bottom of the control. You also adjust the
width of the DetailsView control by dragging the
right-hand border.
Now you can run the page to see the results. You
discover that, as you select rows in the GridView,
the DetailsView shows the values for that row.
Moreover, using the links at the bottom of the De-
Figure 5: Modifying the columns displayed by the GridView control tailsView, all the values (except for the primary key)
are available for editing. You can even insert new
rows. It looks rather like a traditional executable
data access application, yet you have built it in less
than an hour – and you still have not had to write
any code at all.

Working with Data Exposed


Through a Business Object
Just as you are leaning back and admiring your
handiwork, the phone rings again. This time, it is
the senior developer at AdventureWorks Trading
Inc. – and he is not a happy fellow. His team has
spent months building an object-oriented business
and data access layer, and they do not approve of
people using SQL statements to access the data-
Figure 6: Enabling sorting and paging in the GridView tasks pane base directly. This n-tier architecture approach is a

22 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Book Excerpt
common scenario, and you probably should have
known better at the start. The SqlDataSource can
use stored procedures instead of SQL statements,
but to use a data layer based on business objects
means more significant changes are required.
However, all you actually need to do is change
the controls that expose the data (the SqlData-
Source controls) for controls that can commu-
nicate with business objects. AdventureWorks
can provide a .NET managed code assembly that
implements their data access layer, so all you have
to do is switch to using this in place of direct data-
base access.
However, first you must install the business
object. As it is a .NET assembly, there is no registra- Figure 7: Applying an Auto Format to the GridView control
tion required. A compiled DLL can just be dropped
into the bin folder of the application, and then
referenced in the pages. What happens if the code
is not compiled? In that case, you can run the com-
piler from the command line, or use Visual Studio
to compile it, and then deploy.
Even better, in ASP.NET 2.0, you can deploy the
source code and leave it to ASP.NET to compile it
and register it with the application at runtime. Files
placed in the App_Code subfolder of the applica-
tion root folder are compiled automatically as
soon as the application starts (when the first hit is
received), and the compiled code is stored on disk
for use in subsequent hits. If you edit or update the
source code file, it is automatically recompiled and Figure 8: Enabling editing in the tasks pane of a GridView control
the application restarts.
The (extremely simplified) data access compo- DropDownList of categories to the GetCategoryList
nent provided by the AdventureWorks team is a method, because this method accepts no param-
single class file named DataLayer.cs containing eters. The ObjectDataSource for the GridView
public methods that return the data to be displayed control requires a parameter, and this is specified
in the page (it does not support updates to the in the third step of the Configure Data Source
data). The three methods it exposes are named Get- Wizard – it recognizes that a parameter is required,
ProductsByCategory, GetProductByProductID, and and you link it up to the SelectedValue property
GetCategoryList, as shown in Listing 2. of the DropDownList just as you did when using a
The data access class listed here is designed to be SqlDataSource control earlier.
only a basic demonstration of using the ObjectDa- Having added a third ObjectDataSource control
taSource control. A “real-world” example would to replace the SqlDataSource that populates the
generally contain a great deal more code, incorpo- DetailsView control, you just connect the Drop-
rate update methods, and use stored procedures DownList, GridView, and DetailsView controls to
rather than declarative SQL statements. the new data source controls using the tasks panes
The ASP.NET page calls these methods, via the for each one. Because the data layer does not sup-
data source control, to fetch rows from the data- port editing, the tasks panes do not display the
base table. Therefore, the next step after deploying Enable Editing checkbox.
the data access class file is to remove the SqlData- Now you can run the page, and see that – with
Source controls from the page and replace them the exception of editing features – the results are
with instances of the ObjectDataSouce control. the same . This is just what you want and expect,
Using the Configure Data Source Wizard for each because the UI has not changed. In addition, the
one, you connect these controls to the data access work involved in changing to a data access/busi-
layer so that they can expose the same rowsets as ness object layer from declarative SQL statements
the SqlDataSource controls did. No changes are re- is not difficult or time-consuming.
quired to the UI of the page, and – besides the data-
access layer class – there is still no code required! Caching the Data to Reduce
Figure 9 shows the only two steps required to Database Access
connect the ObjectDataSource that populates the It has taken a couple of hours to build the new

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 23


Book Excerpt

aspnet_regsql (in the %windir%\Microsoft.NET\


Framework\[version] folder of your machine) to
prepare the database and the table containing your
source data. You also have to edit your Web.Config
file.
In SQL Server 2005, database cache invalida-
tion depends on the Broker Service feature of the
database. This allows a SqlCacheDependency to be
linked to a data source control so that the data is
cached within ASP.NET and only refreshed from the
database when it changes (or when another notifi-
able event such as a server restart occurs on the
database server). All that is required, when you use
the data source controls, is to add an OutputCache
directive to the page that includes a SqlDependen-
Figure 9: Configuring the ObjectDataSource for the DropDownList cy attribute.

<%@OutputCache SqlDependency=”CommandNotification”
Duration=”60” VaryByParam=”*” %>

Note that you must enable the Broker Service for


the database, and grant the relevant permissions,
before using the Command Notification architec-
ture. For more details, see http://msdn.microsoft.
com/library/ enus/dnvs05/html/querynotification.
asp.
Now you can run the page and then refresh it
without causing a database query to occur (you can
monitor database activity using the SQLProfiler
tool that comes with SQL Server). However, if you
open the source table in Visual Studio or Visual Web
Developer and change one of the column values,
Figure 10: The AdventureWorks Master Page in Design View in Visual Studio you will see that the next time you refresh the page
there is a hit on the database.
page for Margaret at AdventureWorks Trading
Inc., and you are ready for a break. However, Lucy Using a Master Page to Give a
(the database administrator), has just been told Consistent Look and Feel
about the new features in the application. It is her The styles you applied to the GridView and De-
job to keep the database running smoothly and tailsView controls, using the Auto Format feature,
efficiently, and she is worried that you are going to provide a reasonably attractive outcome. However,
slow things down. You are generating constant hits they say that beauty is in the eye of the beholder,
on her database server for every postback as users and so it is no surprise to hear the phone ringing
sort, page, filter, select, and edit rows. again. This time, Juan-Paul from the marketing
Lucy is a great believer in caching data where department is “just calling to say” that they have a
it does not change very often, and wants you to corporate design scheme from their Web site, and
implement this in the new page. No, not next week, he would really appreciate your help to “facili-
but now. It looks very much like the game of golf tate an outward appearance of compatibility for
you were planning is not going to happen today. reasons of enhanced staff resource utilization via
AdventureWorks Trading Inc. uses the new SQL familiarization with the infrastructure.”
Server 2005 database, and so you can take advan- You take a wild guess that he means he wants
tage of a feature called database cache invalida- the new page to follow the same style and layout as
tion to improve performance and reduce database the existing pages. After promising Juan-Paul that
server loading. This makes much more sense than you will “personally endeavor to push the envelope,
the traditional technique of caching for a specific drive the process, and aim skyward toward a satis-
period, based on a best guess as to how often the factory and visually coherent solution,” you fire up
data might change. Visual Studio again.
ASP.NET database cache invalidation supports Luckily, you took advantage of the Master Pages
both SQL Server 2000 and SQL Server 2005. In feature of ASP.NET 2.0 when you built the Adven-
SQL Server 2000, you use the special tool named tureWorks Web site. Therefore, fitting the new page

24 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Catgory Head?
into the existing site simply means converting it Configure Data Source Wizard to select the Web.
from a “normal” Web page into a Content Page sitemap file. Then you drag a Menu control from
and referencing the Master Page file. You did this the Toolbox and drop it onto the Master Page,
because you realized marketing departments have select the new SiteMapDataSource control in the
a changeable attitude to life, and you may well be Choose Data Source list, and use the tasks pane to
required to change the whole design and layout of apply a suitable Auto Format (see Figure 25).
the site at some time in the future. Figure 10 shows You also decide to make it easy for users to tell
the Master Page, with the ContentPlaceHolder where they are in the site hierarchy by adding a
control indicating the area occupied by the content SiteMapPath control to the Master Page as well, at
from each of the Content Pages. The code that cre- the bottom of the right-hand section of the page
ates this page is shown in Listing 3, where you can below the ContentPlaceHolder control. This uses
see the PlaceHolder control within an HTML table. the same Web.sitemap file, and automatically dis-
All that is required is to strip out of the page all plays a “breadcrumb trail” for the current page (see
the <html>, <body>, <head>, <form>, and other Figure 26). In addition, like all the other features of
elements that are not part of the display of rows ASP.NET 2.0 you have used so far, there is no code
from the new Web page. Then add the MasterP- to write! It all just works...
ageFile attribute to the Page directive, and wrap
the content in a Content control that specifies the Summary
ContentPlaceHolder control on the Master Page Although this is a somewhat contrived scenario,
that it will populate. Listing 4 shows how this looks this excerpt has demonstrated just how powerful
in outline. ASP.NET 2.0 is, and how it can considerably reduce
Now, in Design view of the “product list” page, development time while helping you to construct
you can see how the new page fits into the Master efficient and attractive Web sites and Web applica-
Page, with the Master Page itself grayed out and tions. One of the main goals of ASP.NET 2.0 is to
not available for editing unless you open it in a reduce even further the amount of code you have
separate window. At runtime, the Master Page con- to write to build dynamic and interactive pages,
tent merges into the content generated by the new removing, in particular, the need for that repeti-
page you have been building to give the combined tive code you seem to need for almost all of your
result. projects. As you can see from this excerpt, you can
achieve remarkable results without writing any code
Adding a Menu and Other at all.
Navigation Features You have seen how you can create and then
One item missing from the site is a menu that evolve a data access page, starting with dragging
makes it easy to navigate from one page to an- a database table onto the editing window. You
other. Again, ASP.NET 2.0 provides all you need to then saw how easy it is to change the content and
implement various navigation strategies, and the appearance of the grid and then add features like
common and effective solution is often a dynamic sorting, paging, and editing. The next stage added
fly-out or drop-down menu. The data to drive the a category selection capability, so that only specific
Menu control comes from an XML file named Web. sets of rows appear. Following this was imple-
sitemap, which defines the items for the menu, mentation of a “form”-style view of the data. Once
their position within the hierarchical menu struc- the page provided the features required, you next
ture, the pop-up tool-tip for each item, and the saw how you can make it part of an existing site,
target URL for navigation. With the new “products” by matching the overall style and layout using a
page added to the XML file, the menu will auto- Master Page and by integrating it with a menu and
matically provide a link to this page. navigation system. All this was achieved within the
You drag a SiteMapDataSource control from visual design tool, using drag-and-drop techniques
the Toolbox and drop it onto the page, using the and Wizards, and without writing any code at all.

LISTING 1: THE SQLDATASOURCE CONTROL AND ITS </DeleteParameters>


NESTED CONTROLPARAMETER <SelectParameters>
<asp:SqlDataSource ID=”SqlDataSource1” runat=”server” ... > <asp:ControlParameter ControlID=”DropDownList1”
<InsertParameters> Name=”ProductSubcategoryID” PropertyName=”SelectedValue”
... Type=”Int16” />
</InsertParameters> </SelectParameters>
<UpdateParameters> </asp:SqlDataSource>
...
</UpdateParameters> LISTING 2: THE DATA ACCESS COMPONENT IMPLEMENTED
<DeleteParameters> AS A CLASS FILE
... using System;

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 25


Book Excerpt

using System.Data; return null;


using System.Data.SqlClient; }
using System.Configuration; }
public class DataLayer }
{
public DataSet GetProductsByCategory(Int32 category)
{ LISTING 3: THE SOURCE CODE OF THE ADVENTUREWORKS
MASTER PAGE
String connect = ConfigurationManager.ConnectionStrings[
<%@ Master Language=”C#” AutoEventWireup=”true”
“AdventureWorksConnectionString1”].ConnectionString;
CodeFile=”MasterPage.master.cs” Inherits=”MasterPage” %>
String sql = “SELECT ProductID, Name, ProductNumber, Color, “
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.1//EN”
+ “StandardCost, ListPrice, ProductSubcategoryID “
“http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>
+ “FROM AdventureWorks.Production.Product “
<html xmlns=”http://www.w3.org/1999/xhtml” >
+ “WHERE ProductSubcategoryID = @Category”;
<head runat=”server”>
using (SqlConnection con = new SqlConnection(connect))
<title>AdventureWorks Inc.</title>
{
<link rel=”Stylesheet” type=”text/css”
SqlDataAdapter da = new SqlDataAdapter(sql, con);
href=”StyleSheet.css” title=”Default” />
da.SelectCommand.Parameters.AddWithValue(“@Category”, cat-
</head>
egory);
<body topmargin=”0” leftmargin=”0” rightmargin=”0”>
DataSet ds = new DataSet();
<form id=”form1” runat=”server”>
da.Fill(ds, “Products”);
<table width=”100%” border=”0” cellpadding=”0” cellspacing=”0”>
return ds;
<tr>
}
<td align=”left” colspan=”3” bgcolor=”#000000”>
}
<img src=”Images/header.jpg” border=”0” vspace=”0” />
public DataSet GetProductByProductID(Int32 pid)
</td>
{
</tr>
String connect = ConfigurationManager.ConnectionStrings[
<tr>
“AdventureWorksConnectionString1”].ConnectionString;
<td bgcolor=”#000000”>&nbsp;</td>
String sql = “SELECT ProductID, Name, ProductNumber, “
<td style=”padding:10px”>
+ “SafetyStockLevel, Color, FinishedGoodsFlag, “
<asp:ContentPlaceholder id=”CP1” runat=”server” />
+ “MakeFlag, ReorderPoint, StandardCost, ListPrice, “
</td>
+ “Size, DaysToManufacture, Weight, “
<td bgcolor=”#000000”>&nbsp;</td>
+ “WeightUnitMeasureCode, SizeUnitMeasureCode, “
</tr>
+ “ProductSubcategoryID, Style, Class, ProductLine, “
<tr>
+ “ProductModelID, SellStartDate, SellEndDate, “
<td align=”center” colspan=”3” bgcolor=”#000000”>
+ “DiscontinuedDate “
<span class=”footer”>
+ “FROM AdventureWorks.Production.Product “
AdventureWorks Inc. is a fictional corporation.
+ “WHERE ProductID = @ProductID”;
</span>
using (SqlConnection con = new SqlConnection(connect))
</td>
{
</tr>
SqlDataAdapter da = new SqlDataAdapter(sql, con);
</table>
da.SelectCommand.Parameters.AddWithValue(“@ProductID”, pid);
</form>
DataSet ds = new DataSet();
</body>
da.Fill(ds, “Products”);
</html>
return ds;
}
}
LISTING 4: THE OUTLINE STRUCTURE OF A CONTENT
public SqlDataReader GetCategoryList() PAGE
{ <%@ Page Language=”C#” AutoEventWireup=”true”
String connect = ConfigurationManager.ConnectionStrings[ CodeFile=”Products.aspx.cs” Inherits=”Products”
“AdventureWorksConnectionString1”].ConnectionString; MasterPageFile=”~/MasterPage.master” %>
String sql = “SELECT ProductSubcategoryID, Name “ <asp:Content ContentPlaceHolderID=”CP1” runat=”server”
+ “FROM AdventureWorks.Production.ProductSubcategory”; ID=”Content1”>
SqlConnection con = new SqlConnection(connect); ... all page content goes here ...
try </asp:Content>
{
con.Open();
SqlCommand cmd = new SqlCommand(sql, con);
return cmd.ExecuteReader(CommandBehavior.CloseConnection);
}
catch
{

26 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


������������������
���������������������
����������������������
����������������������������������������������������������������������������������������������������������
�����������������������������������������

����������������
���������������������������������������������������������������������������������������������������������������
������������������������������������������������

��������������������������
����������������������������������������������������������������������������������������

�������������������������������
���������������������������������������������������������������������������������������������������������������������������������
��������������������������������������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 27


Feature

A Primer on
Microsoft Atlas
AJAX-ifying your applications
By Jeevan Murkoth

E
ver since the advent of the Internet,
Web applications have lagged behind
desktop applications in terms of inter-
activity and responsiveness. One of the biggest
drawbacks in the conventional Web model has
been the cycle of inactivity between the user
request and the server response. Reducing
this period of inactivity has been the point of
focus for any developer who wants to improve
the responsiveness of Web applications and
raise the user experience to levels offered by
desktop applications.
AJAX (Asynchronous JavaScript and XML) is
one of the approaches that help Web develop- Atlas offers two sets of components, one for client-
ers improve the responsiveness and interactivity of side functionality and another that offers server-
Web applications. As the name suggests, it works by side functionality.
having asynchronous communication between the On the client side, Atlas offers the following:
browser and the server thereby doing away with the • A consistent set of APIs that adds object-oriented
need to re-create the entire page, and reducing the features to JavaScript such as Namespaces and
response time that translates into better interactivity. type system which are very similar to the .NET
However implementing AJAX may not be easy since Framework and let .NET developers easily de-
it involves writing a lot of code in a client-side script- velop in JavaScript
ing language like JavaScript and any developer who • Built-in browser compatibility. The libraries
has worked with one would attest to the fact that handle browser compatibility and there is no
developing and debugging complicated client scripts need to write browser-specific versions.
can sometimes be daunting. It can be even more • An XML-based declarative syntax that lets devel-
daunting to maintain Web applications where the opers do client-side scripting and easily attach
logic is interspersed between client and server code. Atlas behaviors to existing HTML elements.
The Atlas framework from Microsoft promises to
fill this gap and make it easier for the ASP.NET de- On the server side, Atlas provides a set of server
veloper to easily develop interactive AJAX-enabled controls that complements the client-side functional-
About the Author applications. In this article we’ll look at what ATLAS ity. The controls are like any regular ASP.NET control,
Jeevan Murkoth is a Microsoft Certified is and focus on the server controls that an ASP.NET integrate well into Visual Studio, and let the developer
Solutions Developer (MCSD) in .NET (Early developer can use to “AJAX-ify” his applications. extend existing ASP.NET controls with Atlas behavior.
Achiever) and a Microsoft Certified Applica- Atlas also lets the developer integrate ASP.NET
tion Developer (MCAD) in .NET. He currently What Is Microsoft Atlas? services like Profiles, membership roles, and per-
consults for Tennessee Valley Authority and Atlas is Microsoft’s flavor of AJAX. It offers a sonalization from the client-side script. All these
lives in Chattanooga, TN. He has an MS in comprehensive platform that marries client-script- translate into much better productivity for the ASP.
Management Information Systems from Texas ing functionality with ASP.NET server-side features. NET developer.
Tech University. Atlas promises to provide the AJAX capabilities
minus the complexity associated with developing Atlas Server Controls
jeevancm@gmail.com AJAX applications Event though Atlas client-side bits expose a wide

28 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Feature
variety of functionality, I feel that it’s the serve- side specific parts of the page content be updated
functionality and controls that endear it to the ASP. instead of the whole page during post backs. In
NET developer as they automatically emit all the fact for most AJAX functionality to work, it has to
client script needed for the AJAX functionality. For be set to true.
an ASP.NET developer used to doing server-side 2. EnableScriptComponents – This attribute de-
development these controls are a natural choice fines how the ScriptManager references scripts.
since they eliminate the need to master the new If set to true, the ScriptManager automatically
XML-based side-scripting model and write client- references other Atlas scripts that help provide
side scripts. They offer the easiest way to build rich UI behaviors. Some UI behavior scripts are
user experiences because these controls are based AtlasUIDragDrop and AtlasUIglitz. However if
on a programming model that’s already familiar to set to false, it only downloads the scripts that are
the ASP.NET developer. needed for Atlas’s core functionality.
Another major advantage of using server con- 3. ScriptReference – Instead of relying on auto-
trols is that the core application logic would still be matic script registration, it’s also possible to
on the server side. This means that a developer can selectively reference and register scripts by using
go back and easily add Atlas/AJAX functionality to a collection of ScriptReferences. The ScriptRef-
an existing ASP.NET 2.0 application. Out of the dif- erence object exposes three attributes, namely
ferent Atlas server controls, two of them stand out, the ScriptName, Path, and Browser. ScriptName
the Script Manager and Update Panel controls. defines the name of the script being referenced.
ScriptName can either be one of the pre-set
Script Manager Atlas script names like AtlasUIDragDrop or
This control is single-handedly the most impor- AtlasUIGlitz or it can be a custom script that the
tant Atlas server control and as the name sug- developer wants to register. If the ScriptName is
gests manages the different script pieces needed set to one of the pre-set Atlas script names, it’s
on an Atlas-enabled page. Every page that uses automatically referenced. To reference a custom
Atlas server controls should have one instance of script the ScriptName is set to “custom” and the
the Script Manager. First and foremost what the path of the script file has to be specified. The
ScriptManager does is to register the core script file Browser attribute is used to specify the browser
needed for Atlas functionality. where the script will be downloaded.
4. ServiceReference – ServiceReference is similar to
<atlas:ScriptManager runat=”server” ID=”smgr1” ScriptReference, but it’s used to register Web Ser-
EnableScriptComponents=”True” EnablePartialRende vices that may be used in the page. ServiceRefer-
ring=”True”> ence exposes three attributes: the Path that defines
<ErrorTemplate> the path of the service, the GenerateProxy that
<span id=”errorMessageLabel” decides if a proxy is generated for the referenced
runat=”server”></span> service, and the Type attribute used to reference
<input id=”okButton” type=”button” the Web Service by type name.
value=”OK” runat=”server” />
</ErrorTemplate> Now that we’ve seen what the ScriptManager
<Scripts> is capable of, let’s see how it handles the errors or
<atlas:ScriptReference ScriptName=”AtlasUIMap” exceptions that can occur during an asynchronous
/> post back. By default, the ScriptManager traps ex-
<atlas:ScriptReference Path=”~/MyScripts/ ceptions and displays them as a message box. This
MyScript.js” /> may be not be the best way to convey that infor-
</Scripts> mation to the user so the developer might want to
<Services> replace it with one that’s more user friendly. Script-
<atlas:ServiceReference Path=”ComplexService. Manager provides a way for a developer to do some
asmx” /> error handling by defining an OnPageError event
</Services> handler and assigning a custom error message .The
</atlas:ScriptManager> error message can be displayed as an overlay over
the page by defining an ErrorTemplate. At a mini-
The code snippet above shows the markup of a mum, this error template should contain a span or
ScriptManager. As you can see, the ScriptManager div element with the pre-set id errorMessageLabel
control exposes a set of attributes and elements that and a button used to dismiss the error message.
lets us define its functionality. Let’s take a closer look at Before we round up our discussion about the
them. ScriptManager, there’s one more control, the
ScriptManagerProxy that’s a close relative. It’s
1. EnablePartialRendering – Setting this to true used in case the page already has an instance of
controls how the page is rendered and lets the ScriptManager control and one of the controls

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 29


Feature

needs to add a script or a service reference. It can trigger defined below, the UpdatePanel is set to
also be used in a scenario where the Master page refresh when the button is clicked.
has a ScriptManager control already defined and
the content page needs to add scripts or services. <Triggers>
<atlas:ControlEventTrigger
UpdatePanel ControlID=”btnTrigger” EventName=”Click” />
After the script manager, the UpdatePanel is the </Triggers>
next most important Atlas server control. It lets the
developer divide the page into different sections and • ControlValueTrigger – This trigger is fired when
lets each section be updated independently without the property value of a control is changed. In the
refreshing the entire page. This functionality trans- sample code below, the control value trigger will
lates straightaway into better user interactions; partial fire when the textbox text changes.
refreshes are less disruptive than regular full page
refreshes. In reality, the UpdatePanel generates a post <Triggers>
back similar to the regular post back and in fact most <atlas:ControlValueTrigger
of the page events are triggered. ControlID=”txtMessage” PropertyName=”Text” />
The Page.IsPostback even returns a true value for </Triggers>
an update panel post back. Where the UpdatePanel
post back differs from a normal post back in the page TimerControl
lifecycle is in the render event. In the case of an Up- The timer control is used to set a timer event and
datePanel post back, only those regions defined by the refresh the UpdatePanel or the page at set intervals.
UpdatePanel are rendered and sent back to the client. The interval for the timer control is set in millisec-
On the client side, the child controls of the onds. It’s also possible to define a handler for the
UpdatePanel are replaced with the new content. OnTick event. The timer control is a popular choice
This is known as partial rendering. For an Update- as a trigger for an UpdatePanel. The code snippet
Panel to work in partial rendering mode, it requires below shows a timer control.
a ScriptManager with the EnablePartialRendering
attribute set to true. <atlas:TimerControl runat=”server”
Interval=”15000” ID=”tickerTimer”
<atlas:UpdatePanel runat=”server” OnTick=”tickerTimer_Tick” />
ID=”UpdatePanel2” Mode=”Always”>
<ContentTemplate> UpdateProgress
<asp:label runat=”server” Text=”Keep changing UpdateProgress is a nifty little control that lets
me!” ID=”Label1” /> a developer display a templated message when an
</ContentTemplate> asynchronous post back is in progress. It’s used to
</atlas:UpdatePanel> cue the users that something is happening in the
background. The UpdateProgress control defines a
Now that we’re familiar with what partial ren- ProgressTemplate. Any content to be displayed when
dering is, let’s look at the UpdatePanel control in an update is in progress has to be enclosed between
detail .The code snippet above shows the markup the ProgressTemplate tags. In the code snippet
for an UpdatePanel. The UpdatePanel exposes a below, when an asynchronous update is in progress,
ContentTemplate. Any content that needs to be a div tag with an image and text is displayed and it is
replaced by partial rendering needs to be inside hidden as soon as the update is complete.
the ContentTemplate. The UpdatePanel also has an
attribute Mode that defines when the UpdatePanel <atlas:UpdateProgress ID=”upe” runat=”server”>
content would be refreshed. Setting it to Always <ProgressTemplate>
refreshes the content during each and every post <div class=”update”>
back. If this isn’t the case and the UpdatePanel is <img src=”../Images/icons/indicator.gif”
to be refreshed in response to certain events, it’s alt=””/>
possible by setting the value of the Mode attribute Updating....</div>
to conditional. After that, set the trigger that would </ProgressTemplate>
cause the update. The UpdatePanel can accept a </atlas:UpdateProgress>
collection of triggers that would cause an update.
These triggers are classified into two types: Extenders and the Control Toolkit
• ControlEventTrigger – This is a trigger that causes Extenders are a set of controls used to enhance
an UpdatePanel refresh in response to a control or extend the behavior of existing ASP.NET con-
event. To set a ControlEventTrigger, specify the trols. They offer a variety of functionality and let
ID of the control and the name of the event that developers easily spruce up their Web sites with
would trigger the update. In the control event little or no effort. The Atlas framework provides a

30 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Feature
set of extenders out-of-the-box and support for the other is the DragHandleID, which is the control
creating new ones. Although a lot of the current that will act as the handle to move the panel.
crop of extenders that provide client-side behavior DropShadowPanel – If you need a quick way to
have little to do with AJAX, having these behaviors specify a shadow around a panel, this is the extend-
packaged as a control makes it easy for a developer er to use. It also lets the user set the width, opacity,
to use them and reuse the logic elsewhere. and the rounded corners of the shadow.
The control toolkit is a collection of extenders. It Roundedcorners Extender – This extender renders
provides the developer with a way to develop reusable rounded corners for the target element.
Atlas controls and includes the full source code, docu- CascadingDropDown – This is one of the few extend-
mentation, and samples to help. According to Scott ers that have AJAX functionality .It can be attached
Guthrie, general manager of Microsoft’s Developer to an ASP.NET dropdown list and is used to populate
Division, Microsoft plans to develop the toolkit as a a dropdown list depending on the selected value of
collaborative Open Source project so both Microsoft another one. The extender relies on a Web Service
and non-Microsoft developers can work on it. This to retrieve the values for the dependent dropdown
model would definitely expand the control toolkit by list. This extender requires that the parent dropdown
many more extenders. Let’s take a look at some of the and the related dropdown list control id are set. Also
extenders available in the April CTP version of Atlas. required are the name and path of the Web Service
and the method that would service the request.
AutoComplete Extender – This control extends an AlwaysVisibleControl – This extender lets a devel-
ASP.NET text box by giving it auto-complete func- oper position controls on a page so it floats around
tionality. It depends on a Web Service with a pre- during scrolling and readjusts it position so it’s
defined signature to return the search result. The always visible. It can add this functionality to any
Web Service signature defines the string prefix that ASP.NET control.
is the search criterion and the maximum number Modalpopup Control – The modal pop-up ex-
of results it should return. The code below shows tender lets any control be displayed as a modal
the declaration of an AutocompleteExtender. pop-up on a page. Users can interact with this con-
An AutocompleteExtender has a collection of Auto- trol through two buttons namely OK and cancel.
completeProperties where the id of the target textbox Clicking on either of these buttons dismisses the
control; the service path of the Web Service that will control; however it’s also possible to hook up and
respond to the request from the client, the service call custom scripts when either of them is clicked.
method, and the minimum number of characters ReorderList – This extender implements a data-
that have to be input are set. bound list whose items can be interactively reor-
dered by the user by dragging and dropping them.
<atlas:AutoCompleteExtender runat=”server” TextBoxWatermark – This extender is attached
ID=”autoComplete1”> to an ASP.NET text box and shows a watermarked
<atlas:AutoCompleteProperties message to the user when it’s empty. The message
TargetControlID=”TextBox1” disappears as soon as the user starts typing in the
Enabled=”True” ServicePath=”AutoC text box. It’s also possible to set a css class to set the
ompleteService.asmx” style of the watermarked message.
ServiceMethod=”GetWordList” ToggleButton – This extender displays custom
minimumprefixlength=”1” /> images to depict the checked state of an ASP.NET
</atlas:AutoCompleteExtender> checkbox.
HoverMenu – HoverMenu is an Atlas extender that
CollapsiblePanel – This extender control lets a displays a pop-up panel when attached to any ASP.
developer modify the behavior of a regular ASP.NET NET control. It is also possible to decide where the
panel and make it collapsible. At a minimum, the pop-up panel will appear with respect to the ASP.NET.
CollapsiblePanel extender has to set the Target-
ControlID, which is the panel to be collapsed, and Conclusion
the ExpandControlID and the CollapseControlID, Even though Atlas is still in beta, I strongly urge
which are the controls that will expand or col- you to download the framework and play around
lapse the panel when they’re clicked. The Collaps- with it to get a feel for what’s coming. The Atlas Web
iblePanel also has a set of other attributes that let site (www.atlas.asp.net) is a great resource and has
a developer control anything from the collapsed tons of samples that can be used as a starting point.
size to the display images when the panel is either It also has a very active forum where developers
expanded or collapsed. share their experiences with Atlas.
DragPanel Extender – This extender lets a user eas-
ily make an ASP.NET panel draggable. Like the Col- References
lapsiblePanel, the DragPanel defines a TargetCon- • Atlas: http://atlas.asp.net
trolID that’s the id of the panel to be dragged and •Nikhil Kolhari’s Weblog: nikhilk.net

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 31


Styles

BizTalk Application Styles


What can be done with Biztalk
By Andy Morrison

B
izTalk is a broad and inherently flexible although from a client application perspective it
product that can be used to build a large can appear to be synchronous processing. Message
variety of applications; however, it exists routing refers to the process of determining which
to solve very complicated problems, it has a long subscribers an incoming message should be sent
ramp-up time associated with it, and many people to. Additionally, this application style often involves
simply find it too daunting to consider. As a reac- message transformations from one data and/or
tion to these hurdles, this article will discuss differ- structure format to another data and/or structure
ent application styles that can be built with BizTalk format due to system differences or requirements.
instead of attempting to describe it and its features. All other application styles mentioned in this
A set of questions for determining when BizTalk article except the Business Rules Engine use the
Server could be used will also be presented. messaging application style as the foundation of
We won’t try to cover all the application styles their own style.
that can be built with BizTalk. Some applications
styles are very similar, differing only in why they Business Rules Engine
would be implemented not in how they would be The Business Rules Engine application style is
implemented. We’ll cover the most common styles also used as a foundation for other application
of applications that we’ve encountered. styles. This doesn’t mean that this application style
is simple. In the Business Rules Engine application
BizTalk Application Styles style, business rules are abstracted so that they’re
Real-world applications built with BizTalk Server not compiled. Instead, they;re stored as metadata
will vary widely in how closely they subscribe to and executed in BizTalk’s Business Rules Engine
any one of the following styles and they will often (BRE), which is implemented in the .NET assembly
be a blend of several of the ones presented in this provided with BizTalk. This means the rules can be
article. Industry jargon is avoided when possible modified without requiring re-compilation and in
to keep the descriptions as free from misinterpre- some cases without IT staff involvement.
tation as possible. The application styles will be The Business Rules Engine application style can
presented starting with the simplest and moving be used from BizTalk or as a standalone server-side
on to the most complex but only in a very general rules engine. When used “standalone” the BRE
sense. will need a distributed technology wrapper (Web
Services, .NET Remoting, etc.) to act as a façade.
Messaging This application style can range from being quite
The Messaging application style is one of the simple, such as when it’s used as a configuration
simplest that can be built with BizTalk. It’s also store, to quite complex, such as when it’s used to
the most prevalent application style because it manage complex, frequently changing credit-scor-
serves as the basis for almost all the others. In this ing rules.
application style, messages enter BizTalk from a
About the Author publishing system and BizTalk sends them to one Enterprise Application Integration
Andy Morrison is an enterprise consultant or more subscribing systems. The publishing sys- The Enterprise Application Integration (EAI)
with Digineer, a technology and management tem can send a message to BizTalk or BizTalk can BizTalk application style is a very common applica-
consulting firm. Andy specializes in BizTalk retrieve the message from the publishing system tion style whose complexity varies widely based on
Server, co-founded the Twin Cities BizTalk using a polling mechanism. The publishing pattern the complexity of the applications involved, their
User Group, and is a frequent blogger on used for implementation depends on the scenario data formats, and the messaging patterns used. In
BizTalk topics. His blog can be found at as well as the BizTalk Adapter that’s used. this application style, two or more applications in
http://geekswithblogs.net/andym. This application style is defined by asynchro- the same organization are integrated using at least
nous message processing and routing. Internally, the Messaging application style. Transformation
amorrison@digineer.com all messaging is asynchronous inside BizTalk is almost always involved because the applica-

32 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Styles
tions being integrated usually have different data the last several months.
formats and data requirements. In this application style, standard .NET Web
EAI applications can range from high-through- Services, .NET Remoting objects, or other applica-
put batch-like processes where heavy volumes of tion server technologies are replaced with BizTalk
messages pass from one system to another in a Server and a series of SOAP or HTTP services
short period of time to near-real-time messaging hosted in BizTalk. There are many reasons for doing
where messages flow from one system to another this:
as business events occur. Combinations of these • To prepare for future integration, or future
two types of the EAI application style are common movement to an Application Façade or Service
as well. Oriented Architecture
BizTalk is well suited to this application style and • To use BizTalk’s ability to scale easily to meet
can remove the point-to-point integration solutions increased volumes
that define many existing EAI implementations. • To use the BRE as a core piece of the application
server
Business to Business (B2B) • To use BizTalk’s Business Activity Monitoring to
The B2B BizTalk application style is also a very learn more about the application’s usage and the
common BizTalk application style whose com- data flowing through a system
plexity varies widely. One facet of the B2B style
that can make it more complex than the EAI Ap- This application style can be quite simple, but
plication style is that multiple organizations are because application servers usually have very low
involved which can make project responsibility latency requirements, a large amount of time and
and accountability challenging. Otherwise, it’s very effort may be needed for performance tuning.
similar to the EAI application style except that the
systems involved reside in different organizations. Packaged Integration
Messaging is always involved and transformation The Packaged Integration BizTalk application
is usually involved for the same reasons outlined in style isn’t as common as the other application
the EAI application style. styles. Here an organization that sells a primary
B2B applications also range from high-through- software product provides its customers with the
put batch-like processes to near-real time pro- integration interface to that product by packaging
cesses. B2B applications often involve a suite of the interface into BizTalk solutions. The organiza-
common protocols including FTP, SFTP, FTPS, tion may or may not provide BizTalk Server with a
HTTP, SOAP, SSL, and various EDI protocols. license to its primary product. The complexity of
this style of application varies widely based on how
Application Façade the integration with the primary software product
The Application Façade application style is very is done as well as the potential for a multitude of
common and can range in complexity depending deployment requirements for the BizTalk artifacts.
on the types of applications and their number. In
this style, BizTalk acts as a façade between con- Workflow
sumers that use a service and the application that The Workflow application style is a common
provides the service. This usually requires a low- application style that can be very complex. Its
latency solution because the consumers are often complexity varies with the amount of human
end users utilizing client applications. interaction and the level of flexibility that must be
There are many reasons for using this applica- built into the application. This application style
tion style, including decoupling systems, elimi- is defined by widely varying human interaction
nating point-to-point integration solutions, and in a business process. It is focused on improving
implementing aggregations from multiple provid- a previously manual or semi-automated busi-
ers behind a single façade. ness process and increasing its automation while
When application façade s aggregate informa- improving how people interact with the process.
tion from multiple providers their complexity can This application style can involve recursive
increase greatly because of performance issues, sub-processes, roles, re-assignments, and complex
stale data, down systems, time-outs, conditional business rules, which means that the BRE might
system usage based on context, transformation to a be used as well as other user-focused technolo-
common message format, and filtering. gies such as Business Activity Monitoring, HTTP,
InfoPath, Windows SharePoint Services, the BizTalk
Application Server Replacement SharePoint Adapter, and the BizTalk SQL Adapter.
The Application Server Replacement applica-
tion style is very similar to the Application Façade Hub
except that it’s centered on a single application. The Hub application style is a common but often
This application has become more common over complex application style. A Hub’s complexity will

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 33


Styles

vary based on the number and complexity of the mean SOAP over HTTP. It’s an excellent fit because
messages flowing through it as well as the non-func- BizTalk includes a large number of application and
tional requirements associated with it such as avail- protocol adapters that can be used to integrate
ability, scalability, message priority, and duplicate with many different systems. This means those sys-
message detection. This application style involves tems can be brought into the SOA without having
integrating multiple internal and/or external ap- to write custom components to communicate with
plications usually in a near-real-time manner. Hubs them or act as a façade for them.
are often focused on business events and messages This application style can start off with only a
as opposed to complex business processes. handful of services but if the value of those services
This application style usually contains many is high, the number of services provided through
different message types and consequently many BizTalk can quickly increase .
different transformations to map between the mes-
sage types. BRE and Business Activity Monitoring Business Process Management
use are also common in this application style. The Business Process Management (BPM) appli-
Hub applications can be realized by the addition cation style is the pinnacle of BizTalk applications
of multiple BizTalk solutions in the same BizTalk styles and can be very complex. Its complexity
farm or they can be well-thought-out entities that varies in direct relationship with the complexity
are planned from the solution’s inception. If the Hub of the business process being automated. This
is planned it may involve a new database that the application style is defined by the many busi-
Hub updates as messages pass through it. Example ness processes, workflows, and integrations being
databases include an index database that contains implemented in BizTalk along with heavy business
“pointers” to data in other systems, a database that user involvement. It requires significant Business
contains a subset of data from other systems, and a Activity Monitoring use for realizing information
database that provides caching services. about the processes, workflows, and integrations,
and an overwhelming desire on the part of the
Service Oriented Architecture Enabler organization to improve those business processes,
The Service-Oriented Architecture (SOA) En- workflows and integrations continuously.
abler application style can be quite complex, not A later stage of this application style is to
because of the implementation but because it’s improve the business process, workflows, and
part of an organization’s move to service orienta- integrations so they can be modified at runtime
tion, which can often be difficult. This application based on the near-real-time information being
style is defined by BizTalk enabling an organization gathered from Business Activity Monitoring and
to move towards a Service Oriented Architecture, other sources.
usually with a focus on Web Services. A focus on
Web Services is neither required nor desirable Determining When Biztalk Can Be Used
in all cases. This application style often involves Now that you’re familiar with several applica-
complex business modeling, enterprise security tions styles that can be built with BizTalk Server, a
model design, Web Services protocols, heavy enter- set of questions will be introduced to provide the
prise architecture and business involvement, and reader with a starting point for determining if Biz-
perhaps most importantly, a mind shift among an Talk Server can be used by the reader’s organization
organization’s staff on how to design, implement, or project. If the answer to several questions is Yes,
and manage applications. then BizTalk should be considered.
BizTalk is an excellent fit for this application style
if one subscribes to the belief that SOA doesn’t just SCENARIO QUESTIONS
• Does your solution need to scale easily as mes-
sage volume increases over time?
• Do you have compliance (auditing, legal, etc.)
requirements?
• Do you have a business process that demands
never losing a message?
• Does your environment make heavy use of
business rules or use business rules that change
frequently?
• Do you have many disparate technologies and
systems that have to be integrated?
• Do you have an XML-heavy environment includ-
ing SOAP, XSD, XSLT and XML over HTTP?
• Do you want to eliminate your point-to-point
Figure 1: Relative Complexity of Application Styles integration solutions?

34 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Advertiser Index
TECHNOLOGY CULTURE QUESTIONS ADVERTISER URL PHONE PG
• Is your development team interested in a software framework for
ActiveEndpoints activebpel.org/soa 9
integration and business process automation?
• Does your development team have strong .NET development expe- AJAXWORLD Conf & Expo www.AjaxWorldExpo.com 201-802-3020 36,37

rience? CFDynamics www.cfdynamics.com 866-233-9626 27


• Will your development team embrace non-coding solutions to your ESRI www.esri.com/develop 888-288-1277 6
organization’s business problems?
Forum Systems www.forumsys.com 866-333-0210 21
• Does your development team consist of self-starters who are will-
Franklins.net www.franklins.net 877-273-4838 35
ing and able to learn many new things at once?
• Do you have a practical IT operations staff that is willing to learn a Hosting.com www.hosting.com 800-446-7627 13

new tool because over time it will simplify its work? Intersoft Solutions www.intersoftpt.com/webuistudio 3

Kapow Technologies www.kapowtech.com 800-805-0823 Cover 3


BUSINESS CULTURE GUIDELINES MapInfo www.mapinfo.com/sdk 800-327-8627 Cover 2
• Do you have a business that doesn’t look for huge return on invest-
Parasoft www.parasoft.com/JDJmagazine 888-305-0041x3501 Cover 4
ment on the first tactical application implementation?
Real World Flex Seminar www.flexseminar.com 201-802-3020 41
• Is the business willing to invest in long-term solutions?
• Does your business want to improve its business processes and Synaptris www.intelliview.com/netj 866-99IVIEW 17

learn more about its business? Telerik www.telerik.com/AJAX 5


• Does your business want to partner with IT? Visual Paradigm www.visual-paradigm.com 408-426-8212 45

Summary General Conditions: The Publisher reserves the right to refuse any advertising not meeting the standards that are set to protect the high edito-
rial quality of .Net Developer’s Journal. All advertising is subject to approval by the Publisher. The Publisher assumes no liability for any costs
Several styles of applications that can be built with BizTalk were or damages incurred if for any reason the Publisher fails to publish an advertisement. In no event shall the Publisher be liable for any costs or
presented in this article. They vary in complexity and characteristics damages in excess of the cost of the advertisement as a result of a mistake in the advertisement or for any other reason. The Advertiser is fully
responsible for all financial liability and terms of the contract executed by the agents or agencies who are acting on behalf of the Advertiser.
but BizTalk’s features provide a framework for implementing them all. Conditions set in this document (except the rates) are subject to change by the Publisher without notice. No conditions other than those set forth
in this “General Conditions Document” shall be binding upon the Publisher. Advertisers (and their agencies) are fully responsible for the content
In a subsequent article, BizTalk’s core features and their benefits will of their advertisements printed in .Net Developer’s Journal. Advertisements are to be printed at the discretion of the Publisher. This discretion
be reviewed. includes the positioning of the advertisement, except for “preferred positions” described in the rate table. Cancellations and changes to adver-
tisements must be made in writing before the closing date. “Publisher” in this “General Conditions Document” refers to SYS-CON Publications,
Inc. This index is provided as an additional service to our readers. The publisher does not assume any liability for errors or omissions.

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 35


���������������������������������������������������������������������������������
���������������������������������������������������������������������������������
����������������������������������������������������������������������������������

�����������������������������������
����������������������������������
���������������������������������������������������������������������������������
����������������������������������������������������������������������������������
�����������������������������������������������������������������������������������
��������������������������������������������������������������������������������

���������������������

��������������������������
���������������������������������������������������
����������������������������������
�����������������������������������������������������������������������������������
����������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������

��������������������������������������������������������������������� �������������������������
��������������������������������������������������������������������������� ��������������������������������������������������������������������
����������������������������������������������������������������������� ���������������������������������������������������������������
��������������������������������������������������������������������� �����������������������������������������������������������������
������������������������������������������������������������������� �����������������������������������������������������������������
����������������������������������������������������������������� �����������������������������������������������������

©COPYRIGHT 2006 SYS-CON MEDIA. ALL RIGHTS RESERVED

36 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


�����������������������������������������������������������������������������������
�����������������������������������������������������������������������������������
���
���������������������������������������������������������������������������������
����

�����������������������������
������������������������������
���
���������������������������������������������������������������������������������
���
���������������������������������������������������������������������������������
���
���
���������������������������������������������������������������������������������
���
������������������������������������������������������������������������������������

��������������������������������������������
����������������� ����������������������������������������

����������������������������� �����������������
���������������������������� �������� �������������� �����������
������������������������������� ������� ������������
���������������
������������� ��������������������� ������������
������������������������� ���������������������������������������� ���������
������������ �������������������� �������������������������� ����������������
�������������������� ������������������������������� ������������������������������������� �������������������
��������������������������� �������������������� ��������������������� �������������������
��������������������������� ��������������������������
����������������������������
����������������������������� ����������
������������� �������������������������
����

����� ������

������

���
������������������������������������ ������ ��������������
��������������� ��� ���
���������������������� ������ ���� ��� �����������
���
���������������������� ��������
������� �������� �� ����
��������������� ������������������������������
� ������������
� �������������
� ����������
� �������������
� �����������
����������������
� ��������� ������������������������������
HYATT REGECNY SILICON VALLEY

� �����������
�������������
����������������
�����������
���������������������������������
��������������������������������������������� ���������

���������������������
���������������������������������������

������������������
�������������������������� �����������������������������������������������������������
��������������������������������������������� ��������� ����������������������������������������������������������
��������������������������������������� ����������������������������������������������������������
�������������������������������������������������������������
��������������������������������������
�������������������������������
���������������������������������������� �������������
���������������������������������������

������������������������
�����������
�������������������������������������������������� �����
���������������������������������������������������
���������������������������������������������������������� ����������������������������
��������������������������������������������������� ���������������������������
�������������
������������������������������������������
���������������������������������������������

��������������������������������������������������
VISIT WWW.AJAXWORLDEXPO.COM FOR THE MOST COMPLETE UP-TO-DATE INFORMATION

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 37


Feature

AJAX, Java,
Flash, and .NET
Rich Internet applications market place

By Coach K. Wei

E
nterprise Rich Internet Applications (RIAs) deploying, and maintaining enterprise applications.
are the next evolution of business applica- The impact of RIAs on business will match that of
tion development. There are four different PC desktop computing — bringing operational ef-
approaches to RIA development — AJAX, Java, Flash, ficiency and productivity to a whole new level, while
and .NET — and many different RIA solutions avail- decreasing costs.
able today. This article answers the following ques-
tions: What are enterprise RIAs? Which approach Enterprise RIAs versus Consumer RIAs
should you use? Which solutions are appropriate for In general, Rich Internet Applications can be
you? And how are RIAs being adopted today? classified into two categories: enterprise RIAs and
consumer RIAs. Enterprise RIAs refer to RIAs whose
Welcome to a New Paradigm users are primarily business users. This includes
The Web began as an environment for content internal enterprise IT applications as well as B2B
sharing and small-scale data transfer via e-mail, applications. Consumer RIAs refer to RIAs whose
newsgroups, and so forth. These initial uses quickly users are primarily individual consumers, such as
led to more sophisticated applications particu- consumer Web sites, as well as B2C applications.
larly in the e-commerce arena. However, the Web
wasn’t architected with rich application services in Enterprise RIA Opportunities
mind. Its document-centric model has by and large A growing number of Fortune 1000 companies
thwarted developers looking to leverage the Web as have already adopted Enterprise RIAs or will do so
a platform for enterprise-class applications. in the near future. According to Gartner, “By 2010, at
Beginning in early 2005, popular new Web ap- least 60% of new application development projects
plications like Gmail, Google Maps, and Flickr will include RIA technology, and at least 25% of
awakened the entire Internet community to the pos- those will rely primarily of RIA (0.7 probability).”
sibility of a far richer Web experience. Web develop- Organizations that seek competitive advantage
About the Author ers were quick to discover and leverage the technical or greater operational efficiency are increasingly
Coach Wei currently serves as CTO for approach that these applications used, which was exploiting RIA technology to re-architect traditional
Nexaweb (www.nexaweb.com), developers first termed AJAX (for Asynchronous JavaScript and client/server applications, such as those written in
of the leading software platform for building XML). The excitement around AJAX focused more Visual Basic or Java Swing. RIAs can offer all the rich
and deploying Enterprise Rich Internet Ap- attention on the wide spectrum of Rich Internet features and performance benefits of these “thick
plications. Previously, he played a key role at Application (RIA) development tools and the various client” alternatives, while eliminating the need to in-
EMC Corporation in the development of a approaches available. stall and maintain a custom client on user desktops.
new generation of storage network manage- Gartner calls RIAs “the next evolution of the Web.” Enterprise RIA technology is also of great value to
ment software. Coach has his master’s They represent the next big evolutionary step for companies that wish to improve the performance
degree from MIT, holds several patents, is enterprise application development. They deliver and user experience of traditional HTML-based Web
the author of several technology publications, the high performance and robust functionality of applications. RIAs can radically improve the respon-
and is an industry advocate for the prolifera- desktop or client/server software combined with siveness of browser-based applications because
tion of open standards. the universal reach, no-install deployment, and they enable processing to take place on the client,
centralized management of browser-based apps. thus reducing network demands in comparison to
cwei@nexaweb.com RIAs represent the next paradigm for building, HTML’s inefficient “click-wait-refresh” model.

38 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Feature
Moreover, Enterprise RIAs mesh perfectly chine. The UI can be programmed using .NET
with Service Oriented Architecture (SOA) and controls or Microsoft’s XAML. Client-side logic
Web Services initiatives (see references to Dion is generally programmed in C# or a similar
Hinchcliffe and Dana Gardner). Their role in this language.
model is to deliver SOA-based services to users
via a wide range of devices, while at the same Among scripting-based approaches:
time reducing the cost and complexity associ- • AJAX-based RIAs typically employ a relatively
ated with managing networks and client-side simple browser-based JavaScript library for
deployments. In particular, RIAs can reduce the greater interactivity. The UI is most often defined
need for development teams to create mul- using DHTML/JavaScript; client-side logic is also
tiple interfaces to applications using disparate written in JavaScript. The client-side execution
technologies, as is the case with client/server environment is the browser itself.
and HTML-based architectures today. As SOAs • Flash-based RIAs run in the Flash animation
become the method of choice to deploy both new engine. The UI is defined using SWF (a propri-
and existing business services, enterprises will etary binary format for defining Flash-based
increasingly employ RIAs to bring those services movies) or with XML markup compiled into SWF.
to their end users. Client-side logic is programmed in ActionScript,
a scripting language developed by Macromedia
Approaches to RIA Development (now Adobe).
Though it’s still evolving, today’s RIA marketplace
is already rich in choice, and IT teams are chal- Table 1 summarizes the advantages and disad-
lenged to match technology options with business vantages of these four approaches.
goals. But while there are a variety of approaches
and products available for building and deploying RIA Solutions Today
RIAs, they nearly all fall into one of only two basic There are many RIA solutions available today.
categories: Each of them fits into one of the approaches
• Object-oriented programming (OOP) based ap- mentioned above. Some of the solutions come with
proaches, such as Java and .NET and tooling that can simplify development and main-
• Scripting-based approaches, including AJAX and tenance. Table 2 shows a list of solutions available
Flash today.

The comparative strengths and weaknesses of General RIA Programming Model


the different RIA approaches center largely on the Although there are many different RIA solu-
programming model and application execution tions based on different underlying technology
environment they employ. The programming model platforms, the general RIA programming model is
impacts development and maintenance efforts, the actually converging into a single common model.
availability and cost of developer skills, the avail-
ability of industry and development community Declarative UI Development
support, and such. The execution environment The general RIA programming model is centered
significantly impacts not only application perfor- on using an XML-based UI markup language to
mance, functionality, and reliability but the deploy- create a rich user interface. The XML-based UI
ment model as well. markup provides a much higher level of abstraction
than HTML for building rich user interfaces. XML
Comparing RIA Approaches UI frees programmers to focus on the application’s
In general, OOP approaches confer the advan- core logic and explicitly complements the roles of a
tages of strongly typed object-oriented program- typical enterprise development team (see reference
ming such as improved code maintainability and “XML for Client-side Computing”).
reuse, and are better suited for enterprise-class Below are examples from a scripting-based ap-
applications. Scripting-based approaches offer proach (Laszlo Systems) as well as an OOP-based
the advantages of scripting and are best suited to
quickly finishing simple tasks done.
Among the OOP-based approaches:
• Java-based RIAs generally leverage a client-side
Java engine. Client-side application logic (if any)
is written in Java, while the UI is defined using
XML. The client-side components execute inside
a Java Virtual Machine (JVM) that is typically
embedded in a browser. Figure 2: Example 2 UI Display created by
• .NET-based RIAs rely on a .NET virtual ma- Figure 1: UI created by Laszlo code Nexaweb code

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 39


Feature

approach (Nexaweb). Both are zero-install and can lzx files into the Flash binary format (SWF), deliver
run inside any popular Web browser today without the SWF files for rendering inside a Flash engine,
any software download. and execute the application. Following is an ex-
On the client side, Laszlo requires a Flash engine ample of the Laszlo code:
(Flash 6 and above) while Nexaweb requires a JVM
(JDK 1.1 and above). <canvas height=”450”>
Laszlo is a Flash-based RIA solution. It uses an <window x=”10” y=”10” width=”300” height=”200”
XML UI markup language called “lzx” to describe title=”my window”
the UI and uses ActionScript to code application resizable=”true” closeable=”true”>
logic. The Laszlo server will automatically compile <button x=”10” y=”100”>Hello, World</but-
ton>
Strengths Weaknesses </window>
Java • Broad industry support • Requires a higher programming </canvas>
• Large developer community skill set than scripting
• Widely adopted in the enterprise • Requires a Java Virtual Machine By comparison, Nexaweb is a Java-based
to run the application RIA product. Developers would use an XML-
• Robust performance, scalability,
and reliability based UI markup to create a rich user interface
• Robust OOP model and build client-side business logic by writing
• Designed for team development
client-side Java objects called Managed Client
• Maintainable and manageable code
Objects that are standard Java program objects.
The Nexaweb client runtime dynamically
.NET • Supported by Microsoft • Supported only by Microsoft renders the XML UI markup to present a rich
• Robust performance, scalability, • Requires a .NET Virtual Machine to user interface, and dynamically downloads
and reliability to run applications client-side Java objects to the client side for
• Robust OOP model • Requires a higher programming execution in a “on-demand” fashion. Here is a
• Designed for team development skill set than scripting simple Nexaweb UI that defines a tree and a button
• Maintainable and manageable code managed by a layout manager:

<xal xmlns=”http://www.openxal.org/xal”>
AJAX • Highly compatible with existing HTML • DHTML/JavaScript code is difficult
infrastructure and content to develop and maintain <window title=”New Window”>
<boxLayout orientation=”vertical” pack=”start”
• Built-in support in most browsers — • Not designed for team development
therefore easy to try without needing
align=”stretch”/>
• Performance and functionality
additional software limitations
<tree>
Flash • Supports rich UI features like • Performance and functionality <column/>
animation and video limitations <row expanded=”true”>
• Flash engine is small and widely • Flash designers are not developers <cell text=”Tree Item 1”/>
available (lack of mindshare ammong <row>
• Large Flash designer community enterprise developers) <cell text=”Sub Tree Item 1”/>
</row>
Table 1: Strengths and weaknesses of RIA approaches <row>
<cell text=”Sub Tree Item 2”/>
Runtime Solutions Tooling </row>
Java • Nexaweb Platform • Nexaweb Studio </row>
• jRex <row expanded=”true”>
• Thinlet <cell text=”Tree Item 2”/>
<row>
.NET • XAML (Microsoft) • Visual Studio <cell text=”Sub Tree Item 3”/>
</row>
AJAX • Open Source: </row>
–Dojo, Apache, Kabuki, Rico, DWR... </tree>
• Closed Source: <button text=”OK”/>
–Bindows, Backbase, JackBe, </window>
Isomorphic... </xal>

Flash • Adobe Flex • Adobe Flex Builder As shown in these two code examples, though
• Laszlo Nexaweb uses Java and Laszlo uses Flash, RIA UI
development is conceptually identical between the
Table 2: RIA solutions two different RIA solutions.

40 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


�������������������

�����������������������
���������������������������
�����������������

���������������
�������������������
�������������

����������������������������������������������������������������������
����������������������������������������������������������������������
����������������
�������������������������������������������������������������������������� � �����������
��������������������������������������������������������������������� �������������������������������������
�����������������������
������������������������������������������������������������������������� ✓ ������������������������������������
����������������������������������������������������������������������� ✓ ����������������������
✓ ������������������������������
��������������������������������������������������������������������������� ✓ ��������������������
���������������������� ✓ ������������������������
✓ ��������������������������������
✓ �������������������������������
����������������������������������������������������������������������� ✓ ����������������
������������������������������������������������������������������������� ✓ ��������������������������
✓ ������������������
����������������������������������������������������������������������
������������������������������������������������������������������������ �������������������
������������������������������������������������������������������������ ✓ �������������
✓ ������������������
���������������������������������������� ✓ �����������������
✓ ����������������
✓ ��������������
✓ �����������������������
������������ ������������������ �����������������������������������������
������������������������������������� ✓ ��������������������������
������������������������������ �����������������
��������������������������������������� ����� ��������������������������������������� ����� ������������������������������������� ✓ ������������
�������������������������������
��������������������������������������������������������������������������������� ������������������� ✓ ��������������������������������
�����������������������������

������������ �����������

�������������������� �����������������������������������
����������������������� The Flex® Logo is a Trademark of Adobe Systems Inc. ©Copyright 2006. All Right Reserved

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 41


Feature

Rich Thin whether they choose to build the application as Web


application or a desktop application, and bear with
the problems associated with that particular choice.
Client User Interface User Interface User Interface User Interface
RIAs combine the best of both worlds, enabling de-
RIA Engine RIA Engine RIA Engine RIA Engine velopers to meet different application requirements
UI Logic UI Logic UI Logic without making costly tradeoffs.
In contrast to UI development, the choice of a
Business particular RIA approach — Java, AJAX, .NET, or Flash
Business Logic — has a direct impact on and creates significant dif-
Logic ferences in application logic development. Choosing
a scripting-based solution requires that the logic
Data be written as scripts, which limits the amount and
scope of logic that can be developed and main-
tained cost-effectively. An OOP-based RIA solution
gives maximum flexibility to logic development and
maintenance, but requires a higher-level skill set
Server than scripting.
There’s a code sample of logic development using
UI Logic
Laszlo in Listing 1.
By contrast, OOP-based approaches use an
object-oriented true programming language for
Business Business the application logic development and typically
Business Logic Logic
Logic enforce separation between the logic and the UI
markup. For example, Nexaweb uses standard
Data Data Data Data Java for the application logic called mco. Nexaweb
also enforces a clear separation between the UI
Figure 3: RIA enables flexibility in application logic partitioning and logic, preventing the mixing of the UI with the
logic in the same document for better application
maintenance. Nexaweb separates the UI from the
application logic:

<xal>
<mco:declarations xmlns:mco=”http://nexaweb.
com/mco”>
<mco:mco id=”myMco” src=”com.nexaweb.test.
MyTestMco”/>
</mco:declarations>

<dialog title=”Login Dialog”>


Figure 4: Login Dialog <boxLayout orientation=”vertical” pack=”start”
align=”start”/>
Application Logic Development <label text=”Username:”/>
RIA solutions enable a wide range of options <textField height=”25” text=”enter username
for application logic development. In typical here...” width=”200”/>
HTML applications, most of the logic has to be <label text=”Password:” />
on the server side. In typical desktop applica- <textField height=”25” text=”enter password
tions, most of the logic resides on the desktop. here...” width=”200”/>
RIAs offer significant flexibility so developers put <panel height=”25” width=”100”/>
the logic either on the client side or server side. <button height=”25” text=”Button” width=”100”
They can also adjust the location — ranging from onCommand=”mco://myMco.handleOnCommand()”/>
very limited logic on the client side all the way to </dialog>
almost 100% logic on the client side, as shown in </xal>
Figure 3.
The flexibility in partitioning application logic Nexaweb enables application logic to be written
brings significant benefits. Some applications are using standard Java:
best suited to having all their logic centralized on
the server side while other applications require /**
that the logic run on a local desktop. Traditionally, *
developers have to make tradeoffs depending on */

42 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Feature
package com.nexaweb.test; linear state transitions and fixed usage paths
import com.nexaweb.client.ClientEvent; — using them is comparatively routine.
import com.nexaweb.client.ClientSession;
import com.nexaweb.client.mco.AbstractMco; Classified as either “high” or “low” across both
import com.nexaweb.client.mco.McoContainer; these dimensions, an application falls into one of
four categories as Figure 5 illustrates.
The applications in quadrant A are business-crit-
/** ical and less complex. Users rely on these “helper”
* @author cwei applications to do simple but highly important
* business operations (e.g., an employee portal,
*/ partner extranet, or e-commerce Web site). These
public class MyTestMco extends AbstractMco { applications are used less frequently and/or for
shorter durations (“casual usage level”) than more
public void handleOnCommand() { complex applications. The workflow is typically
ClientSession clientSession = McoCon- linear; users do the same tasks in roughly the same
tainer order each time they interact with the application.
.getClientSessionFromM From a development perspective, the client-side
co(this); development team typically comprises fewer
ClientEvent clientEvent = clientSession. developers than a more complex application would
getEventHandler() require.
.getClientEvent(); A classic example of a high-criticality/low-com-
plexity application is an airline’s online ticketing
//additional business logic here… application. Most users interact with it only oc-
casionally, for a short duration, and in a step-by-step
System.out.println(“Hello, you clicked fashion.
the button!”); Applications in quadrant B are both business-
} critical and complex. These applications are used
for many hours each day to do complex non-linear
}

Business Application Profiles


Choosing the Right RIA Solution
Given the various RIA approaches and solutions
available, selecting an RIA solution can be confus- A Simpler tasks
Complex tasks
Expert usage level
Non-linear workflow
B
Casual usage level
ing. There’s no universal “right” RIA solution. It
Linear workflow Performance and reliability
depends on the application’s requirements.
Business Criticality

Medium-sized development team Maintainability


Large development team
Enterprise Application Requirements
For the purposes of this discussion, it’s useful to Similar to “B” but with
Simpler tasks
categorize the full spectrum of software applications Novice usage level greater cost constraints
that enterprise IT departments build, deploy, and Linear workflow
maintain across two related dimensions: business
criticality and application complexity. D Small development team

Application Complexity
C
• Business criticality concerns the degree to
which an application is critical to running Figure 5: Enterprise application profiles
the business or meeting business objectives.
Disrupting access to a business-critical applica- RIA Approaches and Application Profile Map
tion, or even unacceptable performance, has an
immediate and significantly negative impact on
the business. Other applications are less critical
A B
Application Business Criticality

to operations; if there’s a problem, the user can


wait a few minutes to perform a task without OOP:
major consequences. Scripting: Java
• Application complexity refers to its feature rich-
ness and sophistication from a user’s perspective. AJAX .NET
Some enterprise applications have thousands of Flash
screens, with usage metaphors characterized by
multi-path, non-linear state transitions. (In other D Application Scale, Complexity and User Responsiveness
C
words, you might rarely use them exactly the
same way twice.) Other applications have rather Figure 6: Mapping RIA approaches to enterprise application types

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 43


??????????????

tasks that are central to business operations. The and less business-critical. They are typically written
performance, availability, and scalability of these by a small development team of one or two people.
applications are extremely important. From a devel- Developers’ individual experimentation would fall
opment perspective, maintenance is important and into this category.
may cost more than the initial development. The
development team comprises many developers who Different RIA Technology for
require close collaboration. Different Applications
Examples of high-criticality/high-complexity Seen against the backdrop of business criticality
applications include the trading applications used and UI complexity, different RIA technologies are
by portfolio managers, call center applications and appropriate for implementing or re-architecting the
banking applications accessed by tellers. various classes of enterprise applications.
The applications in quadrant C are complex but As Figure 6 illustrates, the applications in quad-
less business-critical. As a result, they are man- rants B and C are much better suited to OOP-based
aged much more cost-consciously. High-complex- RIA development approaches like Java and .NET, be-
ity/low-criticality applications include some legacy cause these technologies offer better maintainability
applications in which companies wish to minimize and support for team development. Scripting-based
further investments, as well as some corporate R&D approaches are more suited for applications that fall
projects. into quadrants A and D where programming tasks
The applications in quadrant D are less complex are simpler, development teams are smaller, and
maintainability is a less mission-critical concern.
AJAX Client Java Client Table 3 provides details on how different RIA ap-

Unified Development Environment


proaches fit with different enterprise requirements
for application profiles and developer skill sets.
RIA Universal Client Engine Nexaweb Studio (Eclipse) The diverse nature of enterprise application re-
quirements, combined with the clear strengths and
Internet Messaging Bus weaknesses of different RIA technologies, lead to the
inevitable conclusion that “one size does not fit all.”
RIA Servlet No single RIA development approach is ideal for
all enterprise environments. Some requirements are
Enterprise Logic and Data better met by scripting-based RIA approaches, while
SOA Legacy MQ DB others require OOP. And in these two categories, a
particular application need will be better served by
Figure 7: Cross-technology runtime environment for AJAX versus Flash, or by Java versus .NET. In short, all
RIAs (Source: Nexaweb) four of these RIA technologies are likely to co-exist in
many enterprise environments for the near future.
RIA
Approach Suitable Application Profile Developer Fit
Interesting New Developments
Java • Transaction-oriented applications • Java Developers
All RIA solutions are fundamentally constrained
• Responsive user interaction and
runtime performance are important by their underlying technology — AJAX, Flash, Java,
• Expert use pattern applications or .NET. If a developer picks Flex to develop his RIA,
(frequent usage, long duration usage) he has to live with the pros as well as cons of Flash.
• Performance, scalability, and Likewise, if a developer picks an AJAX toolkit to
reliability can’t be sacrificed
• Applications that must be
develop his RIA, she must live with the various chal-
maintained for many years lenges associated with DHTML and JavaScript. As
we mentioned earlier, among the four technologies,
.NET • Suitable application profiles are • .NET Developers
similar to Java each has its strengths and weaknesses. One of the
major goals of enterprise IT departments is “com-
AJAX • HTML-centric or Web content-oriented • JavaScript developers
applications (CSS, DHTML, JavaScript,
mon flexibility” — providing standardization and
• Casual use pattern
cross-browser skills) simplification across different business applications
and initiatives, while enabling flexibility for innova-
• Fast application loading and startup
are important tion within business units. Different business units
• Limited client-side logic have different programmer skills and therefore need
(lower maintenance requirement) different types of applications. As a result, dictating
the use of one RIA technology across a large organi-
Flash • Casual use pattern • Flash/Flex developers
zation is unlikely to work well.
• Limited client side logic
(lower maintenance requirement) There’s been a very interesting development in
• Rich media-oriented applications the RIA marketplace recently: cross-technology
RIA solutions. Both Laszlo Systems and Nexaweb
Table 3: RIA enables flexibility in application logic partitioning recently announced that their products are sup-

44 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 45
Feature

porting more than one technology so that the Figure 7 shows cross-technology RIA solution
same application can be delivered and rendered architecture.
on different technology platforms. Laszlo sup- Listing 2 is a sample application written using a
ports both Flash and AJAX (DHTML). Nexaweb cross-technology RIA solution. It is an RSS reader
supports Java and AJAX. With this development, that would read RSS feeds from Yahoo and display
developers don’t have to fight the “religious war” all the feeds in a table. The code is Listing 2 and the
of JavaScript versus Java, Java versus .NET, or UI screen display is shown in Figure 8.
.NET versus Flash. Such development accommo-
dates not only different developer skill sets, but Enterprise RIA Adoption Today
also opens the door to combining the benefits of Though still in an evolutionary stage, RIAs have
scripting-based approaches with those of OOP- been adopted and proven at many leading organiza-
based approaches, delivering optimal results. tions over the world. Many companies have adopted
RIAs as the foundation for their business applica-
tions and achieved great success.
How broadly have RIAs been adopted? Though
there are no industry-recognized statistics available,
numbers from RIA solution vendors provide some
insight. For example, Adobe claims that Flex has
about 300 customers. Nexaweb claims that its plat-
form has been deployed to over 4,000 enterprises.
It is also meaningful to look at which industries
are adopting RIA. According to a market study done
by Nexaweb in October 2005, RIA adoption spans a
wide range of industries, with no single one domi-
nating. Financial services leads with a 17% share,
followed closely by healthcare, hospitability, and
consumer products.
Figure 8: Screen display of Listing 2 code From an application profile perspective, compa-
nies adopt RIA solutions for many different kinds
of applications, including internal IT applications,
B2B applications, B2C applications, and B2C Web
sites. According to the same Nexaweb research, 48%
of the RIAs deployed today are enterprise business
applications, either B2B or internal, while 45% of
them are deployed as consumer applications.

Conclusion
To leverage the Internet for competitive advan-
tage and lower operating costs, businesses need RIA
solutions to overcome the inherent limitations of the
Web as a platform for developing, deploying, and
maintaining business
Figure 9: RIA adoption by industries (Source: Nexaweb) applications.
There are different approaches based on Java,
.NET, AJAX, and Flash for RIA solutions, and each
approach has its strengths and weaknesses. Given
the diverse application requirements in enterprise
environments, no single approach will be able to
span all enterprise environments. In the end, all four
approaches will co-exist serving different applica-
tion requirements.
Though different RIA solutions may be based on
different technology approaches, the programming
model centered on a declarative UI is common. The
real differentiator is application logic development,
which is determined by the RIA approach used by
the chosen RIA solution. In the end, the application
Figure 10: RIA adoption by application types logic development determines application mainte-
(Source: Nexaweb) nance and scalability.

46 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Feature
Cross-technology RIA solutions are excit- • Laszlo Systems: http://www.lazslosystems.com
ing new developments. Such solutions should • Adobe Flex: http://www.macromedia.com/soft-
enable enterprises to adopt a common model ware/flex/
and framework to meet different application • Laszlo Systems: http://www.openlaszlo.org/lps-
requirements, while still enabling innovation latest/docs/reference/script.html
and accommodating different developer skill • Nexaweb Platform: http://www.nexaweb.com
sets. • Nexaweb jRex: http://www.nexaweb.com
Though relatively young, enterprise RIA solutions • Dojo toolkit: http://www.dojotoolkit.org
have already been adopted by many companies • Rico Ajax toolkit: http://openrico.org/
in many different industries led by the financial • DWR: http://getahead.ltd.uk/dwr/
services. As RIA solutions are further developed, RIA • Thinlet: http://www.thinlet.com
adoption in enterprise environments will continue • Apache Kabuki: http://kabuki.apache.org
to grow. • Nexaweb aRex: http://www.nexaweb.com/prod-
ucts.aspx?id=326
Resources • Microsoft, XAML, and Windows Vista: http://
• M. Driver, R. Valdes, and G. Phifer. “Rich Inter- msdn.microsoft.com/windowsvista/about/#wpfx
net Applications Are the Next Evolution of the • Backbase: http://www.backbase.com
Web.” Gartner Research Note. G00126924. May • JackBe: http://www.jackbe.com
4, 2005. • Isomorphic: http://www.isomorphic.com
• Coach Wei. “XML for Client-side Computing.” • Bindows: http://www.bindows.net
XML Journal. (http://www.sys-con.com/story/ • Laszlo Systems. “Laszlo Systems Announces
?storyid=44013&DE=1). March 10, 2004. Plans To Extend OpenLaszlo Platform to Support
• Dion Hinchcliffe “When the worlds of SOA and Delivery of Web 2.0 Applications in Browsers
Web 2.0 collide.”ZDNet. http://blogs.zdnet.com/ Without Flash.” http://www.laszlosystems.com/
Hinchcliffe/?p=35). April 2006. company/press/press_releases/pr_mar_06.php.
• Dana Gardner. “Nexaweb draws a brilliant bead March 2006.
between SOA and AJAX values.” ZDNet, http:// • Nexaweb. “Nexaweb To Introduce Ajax Devel-
blogs.zdnet.com/Gardner/index.php?p=2269. oper Edition.” http://www.nexaweb.com/news.
March 2006. aspx?id=329. March 2006.

LISTING 1 source=”http://rss.news.yahoo.com/rss/topstories”
<canvas debug=”true” height=”200” width=”400”> xmlns:data=”http://www.openxal.org/data” />
<script> <rootPane>
<![CDATA[ <borderLayout/>
// Add a find method to Array <label img=”yahoo_news.gif”
Array.prototype.find = function (what ) { borderPosition=”north”/>
for (i in this ) { <table borderPosition=”center”>
if (this[i] === what) { <column>
return i; <header text=”Title”/>
} </column>
} <column>
} <header text=”URL”/>
</column>
sneaky = {example: ‘sneaky’}; <column>
tryit = [‘foo’, 42, sneaky, Math.PI, false]; <header text=”pub Date”/>
</column>
Debug.write(“42 is at: “ + tryit.find(42)); <data:iterator xmlns:data=”http://www.openxal.
Debug.write(“false is at: “ + tryit.find(false)); org/data”
Debug.write(“’bar’ is at: “ + tryit.find(‘bar’)); dataSource=”yahoo” type=”ONE_WAY” name=”newsIterator” se-
Debug.write(“{example: ‘sneaky’} is at: “ + tryit. lect=”//item”>
find({example: ‘sneaky’})); <row>
Debug.write(“sneaky is at: “ + tryit.find(sneaky)); <textView>{*(‘title’)}</textView>
]]> <link text=”{*(‘link’)}” alignHorizont
</script> al=”left”/>
</canvas> <cell text=”{*(‘pubDate’)}”/>
</row>
Source: Laszlo Systems </data:iterator>
</table>
</rootPane>
LISTING 2 A SIMPLE RSS FEED APPLICATION </xal>
<xal xmlns=”http://www.openxal.org/xal”>
<data:documentDataSource id=”yahoo” Source: Nexaweb

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 47


Book Review

Pro ASP.NET 2.0 in C# 2005 and


Pro ASP.NET 2.0 in VB 2005
The book for ASP.NET professionals
Reviewd by Dennis Hayes

T
his is a big book weighing in at over 1,200 with Visual Studio, WebForms including validation,
pages. Note the “Pro” in the title. If you events, and the page class, server controls (with
want to learn how to design Web sites, this more validation), and ASP.NET application basics
book is not for you; it’s meant for the professional such as configuration, .NET components, and
Web designer needing to build serious, real-world working with HTTP handlers. This part closes with
Web sites that are scalable and secure. This is the a chapter on state management.
complete book for the professional; it covers all the The database section covers all databases parts
basic parts such as the history of ASP.NET, Visual as they pertain to Web pages, but I’d also recom-
Studio 2005, upgrading old projects, and Web- mend that you add good books on database design,
Form basics, but these are covered fleetingly and database administration, and ADO.NET (such as
assumes the reader already knows the concepts ADO.NET 2.0 from Apress, reviewed in DNDJ Vol.
and has enough experience to figure out the details 4 Issue 2). The chapter on ADO.NET fundamentals
for himself. For those getting started in ASP.NET covers basics such as ADO.NET classes, connection
pooling, stored procedures, and transactions. Two
things I like about this chapter are the discussion
of SQL injection attacks and the section on writing
code that can be used with different databases.
This section has a chapter on data binding and
another one on data binding to advanced controls
such as grid and form views. You cannot have too
much information on these topics. It also has a full
chapter on data caching, including SQL Server 2000
and 2005. The section closes with chapters on XML
data, including discussions on when it makes sense
to use XML databases and chapters on files and
streams.
The third section, Building ASP.NET Web sites,
covers basic controls, themes, master pages
(including dynamically setting the master page),
and Web site navigation. This section includes a
short chapter on resources and localization, and
a chapter that goes into detail on Web site deploy-
ment, the differences between IIS 5 and IIS 6, and
side-by-side execution.
or Web development in general, I recommend The fourth section covers all aspects of security
Beginning ASP.NET in C# 2005 from Apress (ISBN in depth. In my opinion, this is one of the most
1-59059-572-6) or Microsoft ASP.NET 2.0 Step by important and difficult areas of Web development,
About the Author Step from Microsoft Press (ISBN 0-7356-2201-9). the one area that separates the pros from the wan-
Dennis Hayes is an independent software This book is divided into six major parts, core nabes.
consultant in Atlanta, GA, and has been concepts, data access, building ASP.NET Web sites, It starts with an overview of security including
involved with the Mono project for over security, advanced user interfaces, and Web Ser- how Web sites are attacked and how attacks can
four years. vices. be prevented with authentication, authorization,
The core concept section covers the advantages SSL, roles, impersonation, gatekeepers, and lay-
dennisdotnet@yahoo.com that ASP.NET has to offer, along with getting started ered security. It then goes into detail about forms

48 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


u c tfo r!y
d
ibnstcrroiption o fer
su
uncotfo ry
intcrroipd
tio
fer!
su bs

authentication, which uses a secure cookies- and


programmer-supplied login page, and how it differs
from membership-based security. Membership-
based security uses .NET 2.0 security controls and
the membership class and API to provide security.
A TRULY INDEPENDENT
A TRULY INDEPENDENT
This includes the login control, one of the cool-
est new controls in ASP.NET. It accepts usernames
VOICE IN THE WORLD OF .NET Here’s what you’
everylissue
Here’s what you’ll find in
l findof .innetdj:
VOICE IN THE WORLD OF .NET every issue of .netdj:
.NET Developer’s Journal is the leading

and passwords, and automatically verifies the user. independent monthly publication targeted at .NET Security Watch
Mobile .NET
developers, particularly advanced developers. It brings
Related controls let users .NETset up accounts,
Developer’s change
Journal is the leading .NET developers everything they need to know in order
.NET Trends

passwords, and e-mail users their password if they to create great software. Security Watch
Tech Tips
independent monthly publication targeted at .NET Standards Watch
forget them. It discusses Windows’ authentica- Published
Mobile .NET Business Alerts
developers, particularly advanced developers. It brings monthly, .NET
tion and impersonation, which uses the built-in Developer’s .NET Trends
.NET News
Book and Software
.NET developers
authentication capabilities of the everything
Windows they need to know in order
operat- Announcements
Journal covers
Tech Tips
ing system, but requires
to createa Windows-based
great software. server everything of interest to .NET Developer’s Journal is for .NET
developers of all levels, especially those “in
developers working with Standards Watch
the trenches” creating .NET code on a daily
and client and that users already have logins on
Published Microsoft .NET technolo-
basis:
• For beginners:
Business Alerts Each issue contains step-by-step tutorials.
the server. Its advantage is that it allows the use of
monthly, .NET
gies – all from a • For intermediate developers:

impersonation, where the Web page get the rights completely independ- .NET News There are more advanced articles.
• For advanced .NET developers:
Developer’s ent and nonbiased per-
In-depth technical articles and columns
associated with a Windows account other than the Book and Software written by acknowledged .NET experts.

Journal covers
spective. Articles are care- AnnouncementsRegardless of their experience level, .NET
standard account used by the ISS server. fully selected for their prime SUBSCRIBE ONLINE! Developer’s Journal assumes that everyone
reading it shares a common desire to under-
The security section also ofhas
everything chapters
interest to on technical content – technical www.sys-con.com/dotnet/
.NET Developer’s Journal is for
stand as much .NET
about .NET – and the busi-

details aren’t watered down with


developers of all levels,ness
or Call especially
forces shapingthose “in Our aim
it – as possible.

authorization, roles,developers
and profiles, and closes with is to help bring our reader-developers closer
the trenches” creating and
.NET code
to that on
goal a daily
chapters on cryptography
working with lots of needless opinion and com-
1 888 303-5282 basis:
closer
new issue!
with each and every

Microsoft and custom membership


.NET technolo- mentary. Apart from the technical content, expert ana-
• For beginners:
providers. lysts and software industry commentators keep devel-
Each issue contains step-by-step tutorials.
gies – all from a
The fifth section covers advanced user interfaces,
opers and their managers abreast of the business

forces influencing .NET’s rapid development. SAVE16% • For intermediate developers: ANNUAL
There are more advanced COVER articles. PRICE:

OFF
completely independ-
including the creation of custom server controls
$83.88
Wholly independent of both Microsoft Corporation • For advanced .NET developers:
In-depth technical articles and columns
ent and
that work with different nonbiased per-
browsers, handling view and the other main players now shaping the course of
written by acknowledged .NET YOU experts. PAY

6999
.NET and Web services, .NET Developer’s Journal
state, control state, and
spective. Articles are care- $
SUBSCRIBE ONLINE!
represents a constant, neutral, expert voice on the
THE ANNUAL RegardlessCOVER PRICE of their experience level, .NET
postback events, as well as for their prime
fully selected state of .NET today – the good, the bad, and the Developer’s Journal assumes thatYOU everyone
SAVE
adding design time support Get 12 issues of .NETDJ reading it shares a common desire to under-
www.sys-con.com/dotnet/ for only 69 !
ugly…no exceptions.
technical content – technical stand$as much 99 $13.89
about .NET – and the busi-
to custom controls. It has ness forces shaping it – as possible. Our
OFF THE aim
ANNUAL
details aren’t watered down with or Call isCHANGE
to help bring
COVER PRICE
our reader-developers closer
a chapter on JavaScript, a OFFER SUBJECT TO WITHOUT NOTICE

chapter on using thelots GDI+of needless opinion and com-


1 888 303-5282 and closer to that goal with each and every
new issue!
library to create dynamic
mentary. Apart from the technical content, expert ana-

graphics, and closeslysts


with and software industry commentators keep devel-

SAVE16%
a chapter on Web parts,opers and their managers abreast of the business ANNUAL
another of the coolest ad-
forces influencing .NET’s rapid development. COVER PRICE:

OFF
ditions to ASP.NET 2.0. It
includes information on
ing the supplied Web parts
and
Wholly independent of both Microsoft Corporation
us-
and
the other creating
main players nownew ones.
shaping the course of
$83.88
The last section contains three chapters covering YOU PAY

6999
.NET and Web services, .NET Developer’s Journal
Web Services, starting with the
represents basics
a constant, of creating
neutral, expert voice on the $
Web Services, and then going into more detail with THE ANNUAL COVER PRICE
state of .NET today – the good, the bad, and the
YOU SAVE
SOAP, WSDL, and customizing XML serialization
ugly…no exceptions. Get 12 issues of .NETDJ
with attributes or IXmlSerializable, closing with
asynchronous calls, and my personal favorite, secu- for only $6999! $13.89
OFF THE ANNUAL
rity. COVER PRICE
OFFER SUBJECT TO CHANGE WITHOUT NOTICE
I like this book because it covers all the key
aspects of building a secure professional Web site,
and pays special attention to databases and con-
������������������������������������
trols. I especially like the attention paid to security. ������������

The Apress motto is “The Experts’ Voice.” It’s books ���������������������������������

����������� ��������

like this that earn that reputation.

Authors: Matthew MacDonald and


Mario Szpuszta (C#) or Laurence Moroney (VB)
����������������������������� ����������������������

Publisher: Apress ��������������������������������������������������


����������������������

��������������������������������������
�������������
�������������������������������

�����������������������������������������

ISBN: 1-59059-496-7 or (VB) 1-59059-563-7


������������������������

���������
��������
����������
����
���������������

Price: US $59.99
� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �

Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 49


Monkey Business

Summer of Code Projects Announced


By Dennis Hayes

Big 5, Big 50 The complete list of projects sponsored by Mono can be


The Mono project celebrates its 5th anniversary this seen at http://www.mono-project.com/Summer2006.
month. The Mono project was launched in July 2001; I
started following Mono in the press almost immediately, Callisto Multi-Project Release
and soon started checking the homepage. In November The Eclipse project has created an umbrella project for
I downloaded the source, and in February 2002 I started related projects called Callisto. The projects remain sepa-
contributing to System.Drawing and System.Window. rate, and maintain their own project management, but
Forms. they do coordinate their releases with Eclipse, and promise
Counting articles, columns and book reviews, this col- not to break dependant projects. Currently, the projects
umn is my 50th contribution to DNDJ since my first article include business intelligence and reporting tools, a C/C++
on Mono, “What the Monkey Can Do,” was published back IDE, a data tools platform, graphical editor framework, the
in March of 2003. Eclipse project itself, Eclipse Test and Performance tools,
Eclipse Web Tools, and the VE Visual Editor. You can find
Summer of Code Projects Announced out more about Callisto at http://www.eclipse.org/proj-
The list of projects for this year’s Summer of Code has ects/callisto.php. The first release was scheduled for June
been released. Last year Mono sponsored 16 projects; this 30, should be on the market by the time you read this.
year they are sponsoring 17 projects, with two students
from last year returning again this year. Jb Evain worked Odds and Ends
on write capability for Cecil last year; this year he is using Ubiquity hosting now supports .NET on Linux using
that knowledge to write a CIL linker to link assemblies for the Mono project for as little as $5 a month. Details can be
Mono. Michael Hutchinson is the other SOC veteran; he found at http://www.ubiquityhosting.com/.
returns to extend the work he did last year on an ASP.NET SecondLife is a virtual world supporting over 150,000
GUI designer for MonoDevelop, to include full support users on 2,000 CPU cores. Currently, they use their own
for creating and testing WEB pages (see current status at scripting language, but will soon be using Mono. Here is a
http://mjhutchinson.com/journal/2006-03-07/monode- discussion of how they used Mono to do their own version
velop_asp_net_addin_is_live). In addition to the ASP.NET of microthreading: http://secondlife.blogs.com/bab-
GUI designer, MonoDevelop will gain Source Control Inte- bage/2006/05/microthreading_.html, and here is a pre-
gration, a “new class” wizard, and an assembly browser. sentation they gave at the Google Tech Talks: http://video.
Four projects will implement the BitTorrent cli- google.com/videoplay?docid=-5182759758975402950&q=s
ent, server, GUI, and Gstremer interface. The PHP.NET econd+life.
compiler from last year is planned be completed to the SharpDevelop has released RC2, the last release can-
third milestone. One project is expected to produce a new didate before SharpDevelop2 is released. This release is
version 8 compatible VB.NET compiler, which will be able strictly bug fixes.
to bootstrap itself by the end of the summer. Unlike the The Gardens Point Ruby.NET compiler has been
old mbas, this will not be based on the C# compiler. Some released as a beta. Details can be found at http://plas.fit.
redundant checks will be removed from the JIT compiler. qut.edu.au/Ruby.NET/. It is not complete, optimized, nor
A daemon will be created to extend the current Mono local does it interop with other .NET languages, but all that is
transactions to handle multi-process transactions. being worked on. The goal of this release was to pass all 871
Currently, the Mono version of MBuild creates a build standard Ruby tests, which it does; the other issues will be
graph in memory, and then transverses the graph to pro- addressed later. It has a liberal open source type license,
cess the build. One of the SOC projects will write the graph and was funded in part by Microsoft.
to disk instead of to memory, and then process the disk An excellent example of how XGL can be used to create a
image. MBuild will not be split into two halves; however, new type of computer desktop is the “Bump Top” table. Ad-
this will still clean up the code while improving efficiency, ditional information can be found at http://honeybrown.
as well as eliminating the need to rebuild the graph on runs ca/Pubs/BumpTop.html. This is simply a research/thesis
where the build rules do not change. project, but it does show what the future may have in store
Mono now supports local transactions, and one of the for us.
SOC projects will be to write a daemon to support multi- The Mono live CD is being updated to work with the
About the Author... process transactions. latest stable Mono release (1.13).
Dennis Hayes is an independent
Other projects include implementing .NET 2.0 strip con- There is now a Mono installer for Mac on Intel. Mono on
software consultant in Atlanta,
GA, and has been involved with trols, XGL composting, WebParts implementations, a GCC Mac on Intel has been around for a while, but it had to be
the Mono project for over four CIL backend, more work on the PHP.NET complier started installed manually.
years.
last summer, and the elimination of redundant checks in MonoDevelop, the IDE for Linux, is now in the process
dennisdotnet@yahoo.com JITted code. of being ported to Windows.

50 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com


Visit us at www.dontnetdevelopersjournal.com July 2006 Volume: 4 Issue: 7 51
52 July 2006 Volume: 4 Issue: 7 Visit us at www.dontnetdevelopersjournal.com