You are on page 1of 52


Presented by


2005 Volume 3 Issue12

March 13, 2006
New York City
GE 25
Building a custom server control FOR D
Marriott Marquis
Times Square, NYC

Create XML Easily with FOR XML PATH The OO Database Advantage
New FOR XML features simplify XML creation Painless object-oriented databases
US Postage
St. Croix Press
Creating Composite Server
Controls in ASP.NET 2.0
Make new components from old

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

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

Learn more about the MapInfo Location Platform for .NET, 110

access whitepapers and download free SDKs. 001

Contact us at
DBA: “I suspect it’s your application server
code that’s causing the problem.”
App Dev: “It must be a database problem.”

Eliminate the finger pointing with WebLOAD Analyzer™.


Want to accelerate resolution

of Web performance problems?
You can with WebLOAD Analyzer—the only load testing tool
with root cause analysis for .NET and Microsoft Web applications.
WebLOAD Analyzer employs unique “black box” software to
capture actual problems at multiple synchronized levels, enabling
users to drill down to the individual component. By pinpointing
the root cause of all kinds of application problems, WebLOAD
Analyzer reduces problem resolution time by 60%—significantly
improving application performance and eliminating finger pointing
once and for all.

Get a FREE “No more finger pointing” T-shirt. >> > > Learn more at



© RadView Software, Limited.All rights reserved. The Smart Choice in Web Application Testing
J a n u a r y 2 0 0 6 Volume 4 Issue 1

Inside DNDJ 10

Five Development Tools I Wish I Had

By Derek Ferguson ................................................................... 7

Google Maps and ASP.NET BOOK REVIEW Top 10 .NET Books


Create XML Easily with FOR XML PATH

By Jerry Dixon............................................................................ 22


The OO Database Advantage

By Rick Grehan and Eric Falsken ........................................... 26
Creating Composite Server Controls ASP.NET

in ASP.NET 2.0 When Design and

Development First Met
BY WES WEEKS By Nina Meiers...........................................................................34

DataWindow.NET How To:

DataWindow Formatting
38 By Bruce Armstrong ................................................................. 42

The Shape of i-Technology .NET 2.0 Generics

By Dennis Hayes ....................................................................... 48
to Come MONO
Mono Releases Version 1.1.10
and New Roadmap
By Dennis Hayes ....................................................................... 50
4 January 2006 •




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

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

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


Five Development Tools
I Wish I Had
Derek Ferguson
Executive Editor
Seta Papazian
Group Publisher
Mobility Editor EDITOR-IN-CHIEF
Jon Box
Security Editor

Patrick Hynds ’ve been doing a lot of cod- to be able to tell instantly by looking
Open Source Editor ing lately. This has been a at a piece of code who added a certain AUTHOR BIO:
Dennis Hayes
Product Reviews Editor bit of a departure from my line of it, and when? It would make it Derek Ferguson is an
Doug Holland
VB Editor usual work as a technology so much easier to figure out whose associate director in the
Keith Franklin evangelist or a development manager, butt needed kicking when you see rank Information Technology Group
Smart Client Editor
Tim Huckaby but – as you might imagine – it has stupidity. at Bear Stearns, a leading global
BizTalk Editor
Brian Loesgen been quite a lot of fun! Having said this, investment banking, securities,

the process of actually sitting down Automated File Use Request trading, and brokerage firm. and coding for 12 hours a day over the In keeping with the topic of source
Derek Ferguson past few months has left me wishing control for a moment… we have been
Seta Papazian
Jeremy Geelan that Visual Studio .NET shipped with using Source Safe. There are quite a
Thom Robbins
John Gomez a handful of additional capabilities in few of us on the team and we have not
Scott Hanselman
Dean Guida the box. (because it never works out right) turned
John Sharp on multiple check-outs. This means
Jacob Cynamon
Chris Mayo Track Changes that I have to e-mail people two or three
Gary Cornell
Joe Stagner If you’ve ever written a book – or times a day – every day – to ask them if I
Peter DeBetta even an article – you have probably could please use their files. I’d like to be
Nancy Valentine encountered the “track changes” fea- able to ask Visual Studio to do this for
Online Editor ture of Microsoft Word. By turning on me, right off the dialog where it tells me
Roger Strukhoff
change tracking, every modification that a given file is currently in use.
Bruce Armstrong, Jerry Dixon, Eric Falsken, Derek Ferguson,

“It would make it so much easier to figure

Jeremy Geelan, Rick Grehan, Dennis Hayes, Nina Meiers,
Jeevan Murkoth, Wes Weeks

For subscriptions and requests for bulk orders,
please send your letters to Subscription Department
Subscription Hotline:
out whose butt needed kicking when you
see rank stupidity”
Cover Price: $6.99/issue
Domestic: $69.99/yr. (12 issues)
Canada/Mexico: $99.99/yr. Overseas: $129.99/yr.
(U.S. banks or money orders). Back issues: $12/ea.,
plus shipping and handling.

EDITORIAL OFFICES that is made to a document is recorded Remote Desktop for Two Monitors
SYS-CON Media 135 Chestnut Ridge Rd., and a history of changes is kept. This If you have two monitors at the
Montvale, NJ 07645
Telephone: 201 802-3000 Fax: 201 782-9638 may sound a lot like source control and, office, drag some of your windows
.NET Developer’s Journal (ISSN#1541-2849) is
published monthly (12 times a year) for $69.99 by in fact, it is. (like Solution Explorer) onto your
SYS-CON Publications, Inc.,135 Chestnut Ridge Road,
Montvale, NJ 07645. There are two important differ- second monitor, and then try to
Postmaster: Send address changes to: ences. The first is that, whereas source Remote Desktop into your worksta-
.NET Developer’s Journal,
SYS-CON Publications, Inc., control specializes in storing multiple tion when you get home. You will dis-
135 Chestnut Ridge Road
Montvale, NJ 07645 historical versions of a given document cover that Remote Desktop only gives
Copyright © 2004 by SYS-CON Publications, Inc. at a central location where multiple you access to your primary monitor
All rights reserved. No part of this publication may be reproduced or
transmitted in any form or by any means, electronic or mechanical, developers can access them via a check- and that it is very hard to get back
including photocopy or any information storage and retrieval system,
without written permission. For promotional reprints, contact Reprint in/check-out process, change tracking the windows that are on your second
Coordinator Dorothy Gil,
Worldwide Newsstand Distribution in Microsoft Word doesn’t do any of this. monitor.
Curtis Circulation Company, New Milford, NJ
Newsstand Distribution Consultant: It just stores additional metadata in a
Gregory Associates / W.R.D.S.
732 607-9941 - single, local copy of a document. Mock Environment Generator/
For list rental information:
Kevin Collopy: 845 731-2684,
The second difference – which is Automatic Expand-and-Collapse-All;
Frank Cipolla: 845 731-3832,
what I would like to see added to Visual for Solution Explorer
Studio to work in conjunction with I lump these two together at the end
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
source control – is the way in which because I am aware of third-party solu-
covered in .NET Developer’s Journal. .NET and .NET-based marks are
trademarks or registered trademarks of Microsoft Corporation in the United
these historical changes are displayed. tions that do both of these things. I’m
States and other countries.
By looking at a document in Word that cheap, though – so I’d like it for free “in
SYS-CON Publications, Inc., reserves the right to revise,
republish and authorize its readers to use the articles is under change control, I can instantly the box.”
submitted for publication.
see (via annotations in the margin) who What tools would you like to see as a
made changes to each bit of it, when part of Visual Studio .NET? Let me know
they changed it, etc. Wouldn’t it be great at! • January 2006

Book Review Top 10 .NET Books President and CEO

Fuat Kircaali
President, SYS-CON Events
Grisha Davida

10 4
Self-Paced Training Guide Jeremy Geelan
Training Kit: (70-320): ADVERTISING
Developing Developing Senior Vice President, Sales and Marketing
Web XML Web Carmen Gonzalez
Applications Services and Vice President, Sales and Marketing
with Microsoft Visual Basic Server Components with Miles Silverman
Advertising Director
.NET and Microsoft Visual C# Visual C# .NET and the .NET
Robyn Forma
.NET, Second Edition Framework Advertising Sales & Marketing Manager
by Microsoft Corporation by Amit Kalani Dennis Leavey

Advertising Sales Manager

Microsoft MCAD/MCSD Megan Mussa
Visual Basic Training Guide Associate Sales Managers
Dorothy Gil
.NET Step by (70-315):
Kim Hughes
Step – Version Developing
Implementing Production Consultant
Jim Morgan
by Michael Halvorson Web Applications with Visual
Lead Designer
C# and Visual Studio.NET Tami Lima
by Amit Kalani Art Director

8 Applied
Microsoft .NET
Programming 2
Visual Basic
Alex Botero
Associate Art Directors
Louis F. Cuffari
Andrea Boden
Video Editor
.NET Version Frank Moricco
2003 (Book & WEB SERVICES
by Jeffrey Richter CD-ROM) Information Systems Consultant
by Francesco Balena Robert Diamond
Web Designers

7 MCSD .NET Stephen Kilmurray

Shawn Slany
Vincent Santaiti
Financial Analyst
(Exam 70-300)
Joan LaRose
Accounts Payable
PROVIDED BY by Randy Cornish Betty White
Accounts Receivable
Gail Naples

6 Programming
President, SYS-CON Events

MCAD/MCSD Self-Paced Grisha Davida
National Sales Manager
Training Kit: Microsoft
Jim Hanchrow
.NET Core Requirements
by Microsoft Corporation
201 802-3012
by Jesse Liberty 888 303-5282

Developing Circulation Service Coordinators
Application Edna Earle Russell
Frameworks in Linda Lipton
JDJ Store Manager
Brunilda Staropoli

by Xin Chen

8 January 2006 •

V E R I O S U P P L I E S T H E B E S T T E C H N O L O G Y, R E S O U R C E S ,

When you partner with Verio, you can

deliver complete solutions for your
customers’ business needs. As your
trusted expert advisor for managed
hosting, we support your application
development with our managed
services and infrastructure from
state-of-the-art Verio data centers.

As a viaVerio® partner, you’ll enhance

your solutions portfolio and add value
to your business by gaining access
to our suite of global products and
services, including managed storage
and security. You’ll also gain peace
of mind in knowing that Verio
is backed by the financial and
operational excellence of NTT
Communications, the world's largest
telecommunications company.


Nothing turns on the power of
the Internet like Verio products
and services.

CALL 866.237.4121 today to find

out more about how a viaVerio
partnership can complete your
business offering. Or visit:

Power. Performance. Results.

Verio, viaVerio and the Verio logo are trademarks and/or

service marks of Verio Inc. in the United States and other
countries. All other names are trademarks or registered
marks of their respective owners. ©2005 Verio Inc.
All rights reserved.

Google Maps and ASP.NET Building a custom server control

am sure that most of developer to write any JavaScript to rendered as a div tag on the page.
you have heard about or accomplish most of the Google Map Once you have the map, it is pos-
have had a chance to use functionality. sible to add controls to the map.
Google Maps. It’s a great Some of the available controls are
service and I was really impressed Some Google Maps Basics the GMapType control that helps to
by the responsiveness of the appli- Before we get into the details of toggle between the different views,
cation and the ease with which the ASP.NET control, let’s look at the namely map view, satellite view,
users could drag and zoom maps basics of the Google Maps API. A and finally, the hybrid view that is
from a Web browser. It has in many detailed description of the API can a combination of map and satel-
ways heralded the arrival of AJAX be found at lite views. The other controls that
(Asynchronous JavaScript and XML), maps/documentation/. The first are usually seen on the map are
which I am sure will revitalize Web step before using Google Maps is to the ones used to add scrolling and
development in the days to come. register for a key with Google (www. zooming capability to the map. At
What makes the service even bet- the time of writing of this article,
ter is the availability of the Google html). This is absolutely free and there are three different controls
Maps API (Application Programming hardly takes a few minutes. Each available:
Interface) as a free Beta service. The Web site that uses Google Maps has • GLargeMapControl: A large con-
API allows developers to embed to have its own key. Make sure that trol for scrolling and zooming
Google Maps in their custom you go through Google’s Terms of • GSmallMapControl: Similar to
applications. It also allows them to Use ( the previous one, but eliminates
overlay information on the map and terms.html) before you start using the zoom scale bar
customize the map to their needs. Google Maps in your application. • GSmallZoomControl: Includes
As I write this article there are quite Google represents an instance only Zooming controls
a few sites that utilize Google Maps, of the map as a “GMap” object. It is
and more and more of them are Once the map has been set up, it
BY JEEVAN MURKOTH appearing by the day. is possible to overlay information on
The API by itself is pretty the map. The information can be in
straightforward and easy to use; the form of points or lines, though
however, it requires the developer to points are the most common ones.
have a good command of JavaScript In order to overlay a point on the
because it extensively relies on cli- Google Map, it’s necessary to know
ent-side Java scripting. In this article its longitude and latitude. At this
we will be looking at building a time, Google does not provide any
custom ASP.NET server control that geo-coding services that give the
would allow a .NET developer to co-ordinates corresponding to an
harness the power of Google Maps address, but there are a couple of
in the code-behind model. We will free services available on the inter-
see how to accomplish most of the net that do so. is
functionality exposed by Google one of them and given a US address,
Maps using this control, and we’ll it returns the longitude and latitude
also see how to data bind the con- for the same. Once the longitude
trol, thereby allowing developers to and latitude have been obtained,
easily build data-driven custom ASP. create an instance of a GPoint
NET Web applications. The control f1 Figure 1: GMap control on the toolbar (which is Google’s representation
would eliminate the need for the in Visual Studio .NET of a point on the map), then create

10 January 2006 •


f2 Figure 2: Output in the Web browser for Listing 2 f3 Figure 3: Output in the Web browser for Listing 3

a GMarker using this point and add more of a .NET wrapper around the the shadow associated with the
the marker to the instance of the Google API; however, because it is icon; IconSize and ShadowSize
Google Map. In order to Center and a full-fledged ASP.NET server-side represent the size of the icon
Zoom on a point, the GMap Object control, it is possible to bind data and the shadow, and the last two
exposes a method ZoomandCenter to the control, thereby increasing properties are IconAnchor and
that takes the point and the level of the usability of Google Maps. In the InfoWindowAnchor, which specify
zoom required as the parameter. Just following sections we will see how the point where the icon should
like points, it is possible to overlay to use this control to implement be anchored to the map relative
lines on the Map. Those of you who most of the common functionality to its top-left corner and the point
have used Google Maps for direc- of Google Maps. Before we do so, where the Info window should be
tions will be familiar with the lines let’s take a look at the control. The anchored to the map.
used to depict the route. In order principal class of the control is the • GLine: This is a line that the user
to add a line to the Google Map, “GMapControl” class. This class in wishes to overlay on the map.
we need to create an instance of turn references the following classes By default it takes a collection
a GPolyLine object and pass in an (most of these classes are the .NET of points (GPoints) as an argu-
array of GPoints to plot it. It is also equivalents of the classes used by ment in its constructor. It is also
possible to assign color, width, and Google): possible to set the color of the
opacity to the line. Another useful • GPoint: This is the class represen- line as well as its weight and
feature in Google Maps is the ability tation of a geographical point and opacity through an overloaded
to show a pop-up window when the exposes latitude and longitude as constructor.
user clicks on a Marker. Google Calls its two properties. • GMarker: This is the .NET repre-
this pop-up window by the name • GPoints: This class represents a sentation of the Google Maps class
“InfoWindow.” collection of GPoint objects. GMarker. The default constructor
• GIcon: Represents a custom accepts an instance of a GPoint
The Google Maps ASP.NET icon that is used as an overlay class. It also has an overloaded
Control (GMAP Control) on the map. The GIcon class constructor that takes a GIcon
The main aim of this control is exposes the following proper- along with the GPoint in case the
to allow .NET developers to utilize ties: the Image URL, which as the developer wishes to use a custom
the functionality of Google maps as name suggests, is the URL of the icon to represent the marker.
a server-side control by writing little image used to represent the icon; • GSize: Represents a two-dimen-
to almost no JavaScript at all. It is ShadowImageURL is the URL of sional size measurement.

12 January 2006 •


f4 Figure 4: Output in the Web browser for Listing 4 f5 Figure 5: Output showing the custom markers

• JScriptGenerator: This is an inter- you want the page to render the Adding to the Toolbar
nal class and has more of a helper GMAP control properly in other This step is optional; however if
function. It generates most of browsers such as Netscape and you are using Visual Studio .NET as
the JavaScript functions that are Firefox, include the browser cap your IDE, I would recommend that
needed by the control. section shown in Listing 1 into you go ahead and add the GMap
• HelperColorConvertor: This class the Web.config file of your control to your toolbox. The advan-
is used to convert a color into its application. tage of doing so is that you can easily
equivalent Hex value. This class is drag and drop the GMap control
marked as internal. Page Configuration onto an ASPX page like any other
• HelperDataResolver: This is an Google has certain recommen- ASP.NET control, and Visual Studio
internal class that helps in data dations for the HTML standards will automatically register the con-
binding and has just one method. on pages that contain the map to trol on your page. Figure 1 shows the
The method casts a datasource make sure that the layout is pre- GMap control on the toolbar.
object into an object that imple- dictable across different browsers.
ments the IEnumerable interface. A detailed description of the same Creating a Basic Map Using
The help file that describes in can be found in the Google maps the Control
detail the different methods and documentation. It is imperative Since we are done with the setup,
properties of the classes involved that you follow these standards, let’s go ahead and create a simple
is available as a download. especially if you plan to overlay example using the control. We will
lines on your map. For lines to be add the GMap control to the page,
Getting Started in ASP.NET rendered on the map, you need to set its dimensions, and make it cen-
Before we use the ASP.NET con- include the VML namespace in the ter and zoom at a particular point.
trol in our application, there are a HTML page for Internet Explorer For the sample application used in
few things that need to be taken browsers. Make sure that you don’t this article, I have saved the map key
care of to ensure that it works as forget to do this, because otherwise in the Web.config file and will be set-
desired. the lines will not be displayed in ting the GoogleMapKey property of
Internet Explorer. The HTML tag of the control from the config file. I will
Web.config File your page should at the minimum be setting the map type of the con-
The GMAP control renders itself look like the snippet below: trol to be that that of “Map.” In case
as a DIV tag, however for non– no map type is specified, the control
Internet Explorer Browsers, ASP. <HTML xmlns:v=”urn:schemas-micro- defaults to the preset “Map.” The
NET renders the div tag as tables. If soft-com:vml”> GMap Control also supports satellite

14 January 2006 •

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 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 ™

f6 Figure 6: Rendering of the line in the browser f7 Figure 7: Multiple Google Map controls – output

and hybrid map types. Make sure Overlaying Markers and Pop-Up icon with any custom icon that we
that you center and zoom at a point, Windows specify. The same functionality is
otherwise all that will show up will Another cool feature of Google provided by the GMap ASP.NET con-
be a grey area. Listing 2 shows the Maps is the ability to display mark- trol. In order to do so, we need to
code for this example and Figure 2 ers on the map and attach pop-up define a GIcon class with at least the
shows the output. windows to these markers on the following properties:
click event. It is possible to dis- • URL of the image that would rep-
Setting the GMap Control play formatted HTML containing resent the GIcon
Properties links and images in these pop-up • URL of the shadow image
Let’s go ahead and set some windows. Let us see how to do • Size of the image
properties to the basic example the same using the GMap ASP. • Size of the shadow
we just created. The GMap control NET control. Let’s take the previ- • The point at which the icon is to
exposes a set of properties that ous example and modify it to add be anchored to the icon
allows the developer to customize two markers. One would be a plain
the control to his or her needs. If marker and the other would have In case info windows are used,
we wish to give the user the flex- a pop-up window that would dis- it is also necessary to specify the
ibility to change the view, we set play some text. The GMap ASP.NET point where the info window is to
the ShowMapTypeControl property control has an overloaded method be anchored to the map. For this
of the control to true. By default, called OverlayMarker that takes the example we will be borrowing the
the user is able to drag the map, formatted HTML as a string param- icons from the Google Ride Finder
however, if we do not wish the eter. If the overloaded method is application. Let’s take the same two
user to drag the map around, we called and some HTML is passed points that we used in the marker
can set the EnableDragging prop- to the method, a click event is example and replace the standard
erty to false. To allow the user to automatically passed to the marker marker icons with these custom
be able to scroll or zoom, set the and the info window is displayed. icons. The code in Listing 5 is same
ScrollControlType property of the Listing 4 shows the code to overlay as that of Listing 4, except for the
control. There are three different two markers and Figure 4 shows the use of custom icons. Figure 5 shows
options: “large,” “small,” and “zoom output of the same. the output.
only,” to correspond to the controls
offered by Google. Listing 3 shows Overlaying Custom Markers Overlaying Lines
the source code and Figure 3 shows Google gives us the flexibility In this section we will see how
the output in the browser. to replace their standard marker to overlay a line on a Google Map.

16 January 2006 •

� �������������� ���������������������
Maps API requires color to be the data source will bind to the
passed in as a Hex value, the GMap latitude field of each marker in the
control takes in a System.Drawing. control
Color structure, thereby making • MarkerLongitudeField: Property
it easier to set the color by name. used to specify which field from
Listing 6 shows the code and Figure the data source will bind to the
6 shows the rendering. longitude field of each marker in
the control
Using Multiple Google Map • MarkerText: Property used to
Controls in a Page specify which field from the data
So far in all of the examples, we source will bind to the Text field of
have dealt with one instance of the each marker in the control (this is
control in a page. It is possible to optional)
have any number of GMap controls • DataSource: Property used to set
in a single page and have granular the source of data
control over each one of them. In
this example, we have four instanc- In this example we will first
es of the control and will center and populate a table with a point and
zoom them on four different cities. then bind it to the GMap control.
Listing 7 shows the code and Figure Listing 8 shows the code involved in
7 shows the output in the browser. It the example and Figure 8 shows the
is possible to have markers or lines output.
on any of these controls.
Binding Data to the Control The Google Maps API is very ver-
f8 Figure 8: Output from Listing 8 The GMap ASP.NET control sup-
ports data binding and it is possible
satile. I hope this control will make it
easier for .NET developers to harness
Lines can be overlaid on maps to to bind it to any data source that the potential of this API.
denote routes, boundaries, or some implements the IEnumerable inter-
other specific purpose a developer face, hence it can bind to most of References
may deem necessary. As in the the commonly used sources such as • Google Maps API documentation:
Google Maps API, the GMap ASP. data tables, datasets, and collections.
NET control also allows overlay As of now the control only supports documentation/
of lines. In the GMap control, the overlaying of standard markers via • Google Maps news groups: www.
GLine class represents a line and data binding. The control exposes
takes a collection of GPoints to plot the following properties that need to documentation/
a line through them. It is also pos- be set before data binding: • Onion, F. (2003). Essential ASP.
sible to set the color, width, and • MarkerLatitudeField: Property NET (Custom Controls). Addison-
opacity of the line. While the Google used to specify which field from Wesley Professional.

Listing 1: Browser Cap Section majorversion=6

<browserCaps> minorversion=0
<case match=”Gecko/[-\d]+”> <case match=”^b” with=”${letters}”>
browser=Netscape beta=true
frames=true </case>
tables=true </case>
cookies=true <case match=”rv:1(\.\d+)(\.\d)(?ʼletters
javascript=true ʼ\w*)”>
javaapplets=true version=7.0
cmascriptversion=1.5 majorversion=7
w3cdomversion=1.0 minorversion=0
css1=true <case match=”^b” with=”${letters}”>
css2=true beta=true
xml=true </case>
tagwriter=System.Web.UI.HtmlTextWriter </case>
<case match=”rv:1.0[^\.](?ʼlettersʼ\w*)”> </case>
version=6.0 </browserCaps>

18 January 2006 •

Listing 2: Basic Map GMapControl1.OverlayMarker(myMarker2);
private void Page_Load(object sender, System. GMapControl1.CenterAndZoom(myPoint,9);
EventArgs e)
{ }
GMapControl1.Height=400; Listing 5: Custom Markers
GMapControl1.MapType=MapControl.GMapType.MAP; private void Page_Load(object sender, System.
GMapControl1.GoogleMapKey=Configuration- EventArgs e)
Settings.AppSettings[“DevKey”]; {
GMapControl1.CenterAndZoom GMapControl1.Width=400;
(new GPoint(36.224264,-86.628273),9); GMapControl1.Height=400;
} GMapControl1.MapType=MapControl.GMapType.MAP;
Listing 3: Setting Properties GMapScrollControl.LARGE ;
private void Page_Load(object sender, System. GMapControl1.ShowMapTypeControl=true;
EventArgs e) GMapControl1.GoogleMapKey=Configuration-
{ Settings.AppSettings[“DevKey”];
GMapControl1.Width=400; GPoint myPoint= new GPoint(36.1645,-86.7811);
GPoint myPoint2= new GPoint(36.224264,-
string sFormattedHtml=”<b><font color=red>
GMapScrollControl.LARGE ;
Nashville</font><b><br> </font><img src=
/><br><a href=http://test >Visit
Nashville </a>”;
GMarker myMarker= new GMarker(myPoint);
//Creating our custom icon
(new GPoint(36.224264,-86.628273),9);
GIcon myIcon = new GIcon();
Listing 4: Overlaying Markers
private void Page_Load(object sender, System.
EventArgs e)
{ myIcon.ShadowSize= new GSize(22,20);

GMapControl1.Width=400; myIcon.IconSize = new GSize(12,20);

GMapControl1.Height=400; myIcon.IconAnchor= new GPoint(6,20);
GMapControl1.MapType=MapControl.GMapType.MAP; myIcon.InfoWindowAnchor= new GPoint(5,1);
GMapControl1.ScrollControlType=MapControl. GMarker myMarker2= new GMarker(myPoint2);
GMapScrollControl.LARGE ; myMarker.Icon=myIcon;
GMapControl1.ShowMapTypeControl=true; GMapControl1.OverlayMarker(myMarker,sFormatted
GMapControl1.GoogleMapKey=Configuration- Html);
Settings.AppSettings[“DevKey”]; myMarker2.Icon=myIcon; myMarker2.Icon.
GPoint myPoint= new GPoint(36.1645,-86.7811); ImageURL=”
GPoint myPoint2= new GPoint(36.224264,- images/mm_20_green.png”;
85.928273); GMapControl1.OverlayMarker(myMarker2);
string sFormattedHtml=”<b><font GMapControl1.CenterAndZoom(myPoint,9);
color=red>Nashville</font><b><br> }
</font><img src=http://localhost/maptest/
images/images.jpg /><br><a href=http:
Listing 6: Overlaying Lines
//test >Visit Nashville </a>”;
private void Page_Load(object sender, System.
GMarker myMarker= new GMarker(myPoint);
EventArgs e)
GMarker myMarker2= new GMarker(myPoint2);
//Overloaded constructor
GMapControl1.MapType=MapControl. • January 2006

GMapType.MAP; GoogleMapKey=ConfigurationSettings.
Jeevan Murkoth is a Microsoft
GMapControl1.ScrollControlType= AppSettings[“DevKey”];
Certified Solutions Developer
MapControl.GMapScrollControl.LARGE ; GMapControl3.CenterAndZoom(new GPoint
(MCSD) in .NET (Early Achiever) and
a Microsoft Certified Application GMapControl1.ShowMapTypeControl=true; (30.32,-97.77),9);
Developer (MCAD) in .NET. He cur- GMapControl1.GoogleMapKey=Configura- //Fourth Control
rently consults for Tennessee Valley tionSettings.AppSettings[“DevKey”]; GMapControl4.Width=200;
Authority and lives in Chattanooga, // Creating the 3 points through which GMapControl4.Height=200; GMapControl4.
TN. He has an MS in Management the line passes GoogleMapKey=ConfigurationSettings.
Information Systems from GPoint pt1 = new GPoint(40.631096,- AppSettings[“DevKey”];
Texas Tech University. GMapControl4.CenterAndZoom
GPoint pt2= new GPoint(35.113813,- (new GPoint(39.57,-75.10),9);
GPoint pt3= new GPoint(33.590040,-
Listing 8: Data Binding in GMap Control
private void Page_Load(object sender, System.
//Adding it to the points collections
EventArgs e)
GPoints ptList= new GPoints();
//Adding it to the points collections
//create the datatable
DataTable dt = new
//Adding the points collection to the
dt.Columns.Add( new DataColumn
GLine myline = new GLine(ptList);
//Setting the Color , weight and
dt.Columns.Add( new DataColumn
dt.Columns.Add( new DataColumn
myline.Weight =3;
//Filling the datatable
for( int i=0; i<10;i++)
DataRow dr= dt.NewRow();

Listing 7: Multiple Controls in a Page dr[“longitude”]=-86.628273+i;

private void Page_Load(object sender, System. dr[“htmltext”]= “<b>POINTER NUM:
EventArgs e) </b> “ +i.ToString();
{ dt.Rows.Add(dr);
//First Control
GMapControl1.Width=200; }
GMapControl1.Height=200; GMapControl1. GMapControl1.GoogleMapKey=Configuration-
GoogleMapKey=ConfigurationSettings. Settings.AppSettings[“DevKey”];
AppSettings[“DevKey”]; GMapControl1.DataSource=dt;
GMapControl1.CenterAndZoom(new GPoint //set the latitude data field
(36.224264,-86.628273),9); GMapControl1.MarkerLatitudeField=
//Second Control ”latitude”;
GMapControl2.Width=200; //set the longitude data field
GMapControl2.Height=200; GMapControl2. GMapControl1.MarkerLongitudeField=
GoogleMapKey=ConfigurationSettings. ”longitude”;
AppSettings[“DevKey”]; //set the text data field
GMapControl2.CenterAndZoom GMapControl1.MarkerText=”htmltext”;
(new GPoint(35.07,-85.27),9); GMapControl1.DataBind();
//Third Control
(new GPoint(36.224264,-86.628273),14);
GMapControl3.Height=200; GMapControl3.

20 January 2006 •

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

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

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


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

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

� � � � � � � � � � � � � � � � � � � �
� � � � � � � � � � � � � � � � � � � �
SQL Server 2005

Create XML Easily with FOR XML PATH

New FOR XML features simplify XML creation

o you love XML? Have it ever was before. I’ve found that elements, in turn, contain multiple

d you been using XML with

SQL Server? Many people
have, starting way back
I haven’t been using the XML data
type nearly as often as I expected.
Instead, I’ve been storing data
SubCategory elements. (Ellipses
are used to indicate sections where
similar elements have been removed
when with SQL Server 7.0. Back then, relationally, creating the XML as for space reasons.) The Category and
there was no support for XML in the needed. I believe that this gives my SubCategory elements each have a
database, so we had to write external applications the best features of both Name attribute. This small, straight-
programs to convert the relational worlds. Therefore, I wish to pass this forward document is complex enough
data into an XML format. This was information on to you. for our purposes.
time-consuming and often inef- This article will introduce some In Listing 2, I’ve created a FOR
ficient. When SQL Server 2000 came of the new XML-creation features in XML EXPLICIT query that creates
out, with its integrated support for SQL Server 2005 and provide some the demonstration document. This
XML, there were a lot of high expec- guidance regarding their use. It will query is representative of those com-
tations. Unfortunately, XML still demonstrate how much easier it is monly created with SQL Server 2000.
couldn’t be easily stored in the data- Notice that there are three individual
base, although it could be created SELECT statements joined together
and consumed. XML could be stored via UNION ALL clauses. Each SELECT
in the database as a large string of statement corresponds to a node in
text, but this was problematic at the resulting XML document. Each
best. Large VARCHAR and TEXT column in the SELECT statements is
strings are hard to manipulate. This named according to a special scheme,
worked, though, and programmers which helps define the structure of
managed to create great systems. the resulting document. There are
Still, something more was needed. also columns (“Tag” and “Parent”)
Many people looked forward to that exist for no other purpose than
the next version of SQL Server, and to define the document schema. To
hoped for a better solution. make matters worse, the ORDER BY
SQL Server 2005 is now here, and clause must be carefully designed
with it comes a new XML data type in order to make the resulting docu-
and support for the new XQuery ment nest properly. While this process
language. XML can now be stored works, with larger documents it can
directly in the database, queried, and quickly become too complex to be
even edited in place. In addition, practical. In addition, because of the
the existing creation and consump- to create XML in SQL Server 2005 fact that it is based on UNION claus-
tion capabilities from SQL 2000 have that it ever was in SQL Server 2000. es, it is highly repetitive. Maintenance
BY JERRY DIXON been enhanced. XML can be created We’ll walk through the creation of a of such queries can become very diffi-
and consumed much more easily small XML document and discuss cult. (I once created such a query with
than ever before. With all of these each step in detail. Because of space 12 individual SELECT statements.
enhancements, how should one pro- limitations, the XML data type and What a nightmare that was!)
ceed? the related XQuery language will be
Last year, I couldn’t wait for the covered in a future column. FOR XML Enhancements
ability to store XML in the database. SQL Server 2005 has a solution
I was sure that this capability would FOR XML EXPLICIT Refresher to these shortcomings. There is a
be the answer to all of my XML-relat- In order to fully appreciate the new PATH directive in the FOR XML
ed problems. Because SQL Server new SQL Server 2005 features, you clause. This directive allows much of
2005 now has an XML data type, we must first understand the difficulties the structure, or schema, of the result-
can store entire documents directly faced by SQL Server 2000 develop- ing XML document to be specified
in a column of a table. I was posi- ers. These are best illustrated with an via XPath. Take the code in Listing 3
tive that this would be the first new example. Let’s examine a simple XML for example. The SELECT statement
feature that I would use. However, document that I created from data in returns a single column whose alias
an unexpected thing occurred along the new AdventureWorks database is an XPath expression. The expres-
the way: Microsoft enhanced the (see Listing 1). The document has sion indicates that the column results
FOR XML clause. It is much easier to a single root element that contains should become an attribute called
create XML from relational data than multiple Category elements. These “Name.” (In XPath, the “@” symbol

22 January 2006 •

indicates an attribute. The lack of this an XML column in a table, or further duced with FOR XML PATH), you’ll AUTHOR BIO:
symbol indicates an element. See an manipulated in T-SQL statements. It see that they are identical. However, Jerry Dixon is a senior devel-
XPath reference for more information.) is this last capability that we will use. the new syntax is much cleaner and oper and architect for ACH
When executed, this code will create With the TYPE directive, we now have easier to create (compare Listings 2 Food Companies in Memphis,
the XML document shown in Listing the ability to nest FOR XML PATH que- and 10 to see this). The performance Tennessee. Over the past 16 years
4. As you can see, this creates an ele- ries. This allows us to create XML docu- of the two implementations is similar, he has led development projects
ment for each row, with the attribute ments of almost any depth. You can see although the execution plan for the for a number of enterprise, mid-
name that we specified; however, each this technique in use in Listing 8. I’ve FOR XML PATH query is noticeably level, and small business organiza-
element is named “row.” This is prob- combined the queries for the Category smaller. Because of this, FOR XML tions. While he has fulfilled multiple
ably not what we would want in our and SubCategory elements, linking PATH queries should edge out FOR roles as an infrastructure designer,
actual document. Fortunately, there is them together with an appropriate XML EXPLICIT queries when larger database administrator, and soft-
a solution for this too. In Listing 5, I’ve WHERE clause. The XML produced is or more complicated documents are ware developer, he specializes in
altered the SELECT statement so that shown in Listing 9. created. When you factor in readability XML, SQL and ASP.NET. He is a
the resulting elements will be named Although the XML document is and maintenance, the new method co-leader and frequent presenter
“Category.” The results are shown in now well formed and properly nested, wins hands down. at the Memphis .NET User Group.
Listing 6. it is not yet valid. XML documents Jerry holds the following Microsoft
If you glance back at Listing 1, should have only one root element. Summary certifications: MCSD (VB 6.0
you’ll notice that we’ve managed to If you look at our document, you’ll When I started using the XML and .NET), MCDBA (SQL 2000),
reproduce the Category elements see that we have four instances of the support in SQL Server 2005, I fully MCSA (Windows 2000 and 2003),
contained in that document. Next, Category element, all at the root level. expected that I would be storing data MCSE (Windows 2000), MCAD
we’ll need to write some code for the We need to change our last query so inside tables as XML. I thought that (.NET), MCT. He resides in Olive
SubCategory elements. This code, that it produces one root element and this would be the easiest way to send Branch, MS with his wife and son.
along with its results, is shown in includes the Category elements under- XML to applications outside the server.
Listing 7. This SELECT statement is neath this new root. To do this, we can As I’ve learned more about the prod- 4
very similar to the one for the Category take advantage of one final enhance- uct, I have seen how the improved
elements, except that the data is ment. The FOR XML clause now has a FOR XML clause makes the creation of
retrieved from a different table and ROOT directive, which indicates that XML documents easier to accomplish
the results get placed in different ele- a root element should be created for and maintain. This has changed my
ments. us. By default, this root element will be perceptions. With the new FOR XML
Now that we have the data for both given the name “root.” If we so desire, PATH clause, we can store our data
sets of elements, we need a way to we can also specify the name of this relationally and easily produce the
combine them together appropriately. root element. In Listing 10 you can see XML when needed. In this way, we can
The new TYPE directive can be used for the query with this directive added. take advantage of the capabilities of
this. The TYPE directive specifies that The final XML document is shown in both data formats. We can use the rela-
the XML created in a FOR XML query Listing 11. tional data in a JOIN, for example, and
should be returned as an instance of We’ve now come full circle. If you produce the XML whenever necessary.
the XML data type. The data can then compare Listing 1 (produced with FOR With SQL Server 2005, the choice is
be stored in an XML variable, placed in XML EXPLICIT) and Listing 11 (pro- now ours.

Listing 1: XML Document <SubCategory Name=”Brakes” />

<XML> ...
<Category Name=”Accessories”> <SubCategory Name=”Touring Frames” />
<SubCategory Name=”Bike Racks” /> <SubCategory Name=”Wheels” />
<SubCategory Name=”Bike Stands” /> </Category>
... </XML>
<SubCategory Name=”Pumps” />
<SubCategory Name=”Tires and Tubes” /> Listing 2: SQL 2000 FOR XML EXPLICIT
</Category> SELECT
<Category Name=”Bikes”> 1 AS ʻTagʼ
<SubCategory Name=”Mountain Bikes” /> ,NULL AS ʻParentʼ
<SubCategory Name=”Road Bikes” /> ,NULL AS ʻXML!1ʼ
<SubCategory Name=”Touring Bikes” /> ,NULL AS ʻCategory!2!Nameʼ
</Category> ,NULL AS ʻSubCategory!3!Nameʼ
<Category Name=”Clothing”>
<SubCategory Name=”Bib-Shorts” /> UNION ALL
<SubCategory Name=”Caps” />
<SubCategory Name=”Tights” /> 2 AS ʻTagʼ
<SubCategory Name=”Vests” /> ,1 AS ʻParentʼ
</Category> ,NULL AS ʻXML!1ʼ
<Category Name=”Components”> ,Name AS ʻCategory!2!Nameʼ
<SubCategory Name=”Bottom Brackets” /> ,NULL AS ʻSubCategory!3!Nameʼ • January 2006

SQL Server 2005 ���
FROM Production.ProductCategory <SubCategory Name=”Bike Racks” />
<SubCategory Name=”Bike Stands” /> ���
<SubCategory Name=”Pumps” />
SELECT <SubCategory Name=”Tires and Tubes” /> ��
AS ʻTagʼ
AS ʻParentʼ
<Category Name=”Bikes”>
,NULL AS ʻXML!1ʼ <SubCategory Name=”Mountain Bikes” /> ���
,c.Name AS ʻCategory!2!Nameʼ <SubCategory Name=”Road Bikes” />
,sc.Name AS ʻSubCategory!3!Nameʼ <SubCategory Name=”Touring Bikes” /> ���
FROM Production.ProductCategory c </Category> ���
INNER JOIN Production. <Category Name=”Clothing”>
ProductSubCategory sc <SubCategory Name=”Bib-Shorts” />
ON c.ProductCategoryID = <SubCategory Name=”Caps” />
sc.ProductCategoryID ...
<SubCategory Name=”Tights” />
ORDER BY <SubCategory Name=”Vests” />
ʻCategory!2!Nameʼ </Category>
,ʼSubCategory!3!Nameʼ <Category Name=”Components”>
<SubCategory Name=”Handlebars” />
FOR XML EXPLICIT <SubCategory Name=”Bottom Brackets” />
Listing 3: FOR XML PATH <SubCategory Name=”Touring Frames” />
SELECT Name AS ʻ@Nameʼ <SubCategory Name=”Wheels” />
FROM Production.ProductCategory </Category>
Listing 10: Adding a Root Element
Listing 4: FOR XML PATH Results SELECT c.Name AS ʻ@Nameʼ,
<row Name=”Accessories” /> (SELECT sc.Name AS ʻ@Nameʼ
<row Name=”Bikes” /> FROM Production.ProductSubCategory sc
<row Name=”Clothing” /> WHERE sc.ProductCategoryID =
<row Name=”Components” /> c.ProductCategoryID
ORDER BY sc.Name
Listing 5: Named Element FOR XML PATH(ʻSubCategoryʼ), TYPE)
SELECT Name AS ʻ@Nameʼ FROM Production.ProductCategory c
FROM Production.ProductCategory ORDER BY c.Name
FOR XML PATH(ʻCategoryʼ) FOR XML PATH(ʻCategoryʼ), ROOT(ʻXMLʼ)

Listing 6: Named Element Results Listing 11: Final Results

<Category Name=”Accessories” /> <XML>
<Category Name=”Bikes” /> <Category Name=”Accessories”>
<Category Name=”Clothing” /> <SubCategory Name=”Bike Racks” />
<Category Name=”Components” /> <SubCategory Name=”Bike Stands” />
Listing 7: SubCategory Example <SubCategory Name=”Pumps” />
SELECT Name AS ʻ@Nameʼ <SubCategory Name=”Tires and Tubes” />
FROM Production.ProductSubCategory </Category>
FOR XML PATH(ʻSubCategoryʼ) <Category Name=”Bikes”>
<SubCategory Name=”Mountain Bikes” />
<SubCategory Name=”Bib-Shorts” /> <SubCategory Name=”Road Bikes” />
<SubCategory Name=”Bike Racks” /> <SubCategory Name=”Touring Bikes” />
... </Category>
<SubCategory Name=”Vests” /> <Category Name=”Clothing”>
<SubCategory Name=”Wheels” /> <SubCategory Name=”Bib-Shorts” />
<SubCategory Name=”Caps” />
Listing 8: Combining the Queries ...
SELECT c.Name AS ʻ@Nameʼ, <SubCategory Name=”Tights” />
(SELECT sc.Name AS ʻ@Nameʼ <SubCategory Name=”Vests” />
FROM Production.ProductSubCategory sc </Category>
WHERE sc.ProductCategoryID = <Category Name=”Components”>
c.ProductCategoryID <SubCategory Name=”Bottom Brackets” />
FOR XML PATH(ʻSubCategoryʼ), TYPE) <SubCategory Name=”Brakes” />
FROM Production.ProductCategory c ...
FOR XML PATH(ʻCategoryʼ) <SubCategory Name=”Touring Frames” />
<SubCategory Name=”Wheels” />
Listing 9: Combined Results </Category>
<Category Name=”Accessories”> </XML>

24 January 2006 •

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


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

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

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

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

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


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

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

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

The OO Database Advantage Painless object-oriented databases

ere’s a question: If you write delete operations on multiple tables. ArrayList collection of components.
your application’s code in (Source code for this article is avail- Members of the components col-
an OO language – such as able from lection are required to assemble this
C#, VB.NET, or managed PartsAssembly/.) PartAssembly.
C++ – why not write database query If we strip away the method defini-
and update code in the same language? Illustration by Example tions for these classes, the structure
It would certainly make life simpler, Suppose you must write an applica- becomes transparently obvious (see
wouldn’t it? At the very least, you’d only tion for an assemblies database – that Listing 1). When implemented in a
have to hold one language in your head is, a database whose content tracks relational database, the class structure
– not your programming language and items that are assembled from “parts.” in Listing 1 would require two or three
SQL. A “part.” in this case, could be just tables, depending on how a person
That’s the very least of the advan- about anything: a screw, a light bulb, a modeled the inheritance relation.
tages you’d gain by choosing an OO spring, or even a software component. In a three-table arrangement, Part
database instead of an RDBMS. The It doesn’t really matter: the idea is that objects would be stored in one table,
metaphor “impedance mismatch” assemblies are constructed by connect- PartAssembly objects in a second,
has frequently been used to illustrate ing parts together, and in turn, more and the contents of the components
the problems that arise from using a complex assemblies can be fabricated ArrayList in a third. (This kind of map-
relational database as the back end to by connecting assemblies together. ping from OO to relational is referred to
an OO application. Admittedly, it’s a The aggregation of lower-level as “horizontal mapping.”) The column
somewhat overused metaphor, but it assemblies continues until a top-level structure of the Part and PartAssembly
still serves its purpose. It illustrates the assembly (or a “finished product”) tables would be identical, because the
fact that relationships among objects is reached. Therefore for example, a only difference between the two – the
– referencing, containment, polymor- motherboard assembly – consisting of components element in PartAssembly
phism, and so on – must be translated circuit board, CPU, and memory part – would be stored in the third table. The
into relational constructs when those objects – is combined with a power- components dictionary table would
objects are stored in the database. supply assembly, a disk-drive assembly, hold two columns, one for the Part, and
Furthermore, the translations require and a chassis assembly to create a desk- a second to reference the PartAssembly
BY RICK GREHAN developer intervention at some point: top system. This structure is illustrated identifier. This second column is a for-
either explicitly in executable code, by in Figure 1. eign key, and provides the connection
creating schema mapping files that a This kind of database is nicely between the components and their
translation layer reads and interprets, or portrayed in an object-oriented struc- “owning” PartAssembly object.
through some other mechanism. ture. The Part class is the fundamental In a two-table solution, Part and
The upshot is that you have to building block. From it, one derives a PartAssembly would share the same
“explain” the object structure of your PartAssembly class (which models an table (this is known as “filtered map-
application to a relational database Assembly from Figure 1, but which we ping”). That table would include
AND ERIC FALSKEN – and in terms that the relational data- renamed in order to sidestep any con- columns for category, name, manufac-
base understands. Sometimes this even fusion with .NET’s meaning of the word turer, and manufacturerPartNumber.
requires you to add elements to one or “assembly”). The PartAssembly class An extra column would be added – call
more of your objects – elements that extends the Part class by adding an it classID – that would be used to dis-
translate to additional columns in one tinguish rows that correspond to Part
of the RDBMS tables, and serve no objects from rows that correspond to
purpose other than to support object Assembly PartAssembly objects.
relationships. The advantage of the three-table
Specifically, suppose you have an mapping strategy is its conceptual sim-
OO application whose objects’ struc- plicity. Each concrete class gets its own
Assembly Assembly
tures exhibit a tree-like or networked table. It is also more easily extended. If,
arrangement. With regard to entities for example, a new class were defined
that your program can treat as a single Part Part Part Part Part that extended PartAssembly, the devel-
(albeit complex) object, the back-end oper would need only to construct a
RDBMS must distribute across multiple f1 Figure 1: The structure of the new table.
rows and (likely) multiple tables. For assembly database fits nicely into On the other hand, the two-table
example, deleting a single tree – which object-oriented grooves. Parts strategy has the advantage of minimiz-
in OO code would be the mere drop- belong to assemblies, and both are ing the number of tables required.
ping of a reference – turns into multiple derived from the same base class. However, adding a new descendant

26 January 2006 •

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

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

� �������������������������
� �������������������
� ������������ �
���������������������������������2�3���� ���������������
�� ��������������������������������������������
��������������������������� ��
�� ��������������������������������������������
�� ������������
���������������������� ��
������������������������������������������������� �� ��������������������
���������������������������������������������������������������� �� ������������
�� �������������
�������������������������������������������������������������������������������������������������������� �� ����������������������������������
�������������������������������������������������������������������������������������������������������� �� ���������������������������
������������������������������������������������������������������������������������������������� �� �����������������������
��������������������������������������������������������������������������������� �� �����������������
�� �� ����������������������������������
��������������������������������������������������������������������������������������������������������� �� �������������������������������������
������������������������������������������������������������������������������������������������� �� �������������������������������
���������������������������������������������������������� �������� ����������������������������������

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

������������������������������������������������������������������ � ���������������������������
������������������������������������������������������������������������� �������� �����������������������������������������������
������������������������������������������������������������������ � ����������������������������������������������
������������������������������������������ �� ����������������������������������������������
����������� � ����������������������������������������������
had occurred since the last commit() or
Part Table PartAssembly Table
open() would be rolled back.
category name manufacturer manufacturerPartNumber category name manufacturer manufacturerPartNumber Retrieving an object from this OO
memory PC-2 5400 DDR Generic 25400 DDR Desktop Sys. Desk Mod 01 My Computers DTM0D01
database is just as easy as storing it. We
cpu Pentium 4 Intel BX8O547PG32OOF
hard drive DiamondMax Maxtor 6Y25OMO6Y25OMO don’t have to assemble an object’s “piec-
Components Table es” from multiple tables; instead, we can
parent part pull it from the database with a single
DTMODO1 PC-2 5400 DDR call. All we need is a query mechanism
(a) DTMODO1 Pentium 4 to identify the specific object we want.
DTMODO1 DiamondMax db4o provides this mechanism via
its QBE (query by example) API. QBE,
as implemented by db4o, is an easy-
PartAndAssembly Table to-understand query technique that
uses a template object to define the
class category name manufacturer manufacturerPartNumber
P memory PC-2 5400 DDR Generic 25400 DDR
query. We fill the template object’s fields
P cpu Pentium 4 Intel BX8O547PG32OOF with those values we want the query to
P hard drive DiamondMax Maxtor 6Y25OMO6Y25OMO match. Fields that should not partici-
A Desktop Sys. Desk Mod 01 My Computers DTMOD)1 pate in the query are set to null or zero
(depending on the datatype).
Therefore, if we wanted to fetch
the Part object we had just stored into
Components Table the database, we could use the code
in Listing 3. The query in Listing 3
parent part
(b) matches all Part objects whose name
field is “Desktop Board D945GNT” (we
DTMODO1 Pentium 4
presume there is only one). Matching
DTMODO1 DiamondMax
objects are placed in the ObjectSet
result. The ObjectSet class provides has-
f2 Figure 2: Two techniques for mapping objects to relational databases. (a) Each class receives its own table.
Next() and next() methods, which allow
The components collection (in the PartAssembly class) is stored in a separate table, with a foreign key reference
navigation-through-iteration on the
back to the “parent” item in the PartAssembly table. (b) Both Part and PartAssembly classes are stored in a
set’s contents.
single table. A column is added to identify the class to which a particular row of data belongs.
The query fetched a Part object
from the database. As defined, the
class to either Part or PartAssembly .NET and Mono versions of db4o are Part object is relatively “simple” – that
(with new data members) would freely available from www.db4objects. is, it contains only strings as member
require adding new columns to the com. variables. The PartAssembly class,
table, as well as new logic to identify the Assuming that we have defined the however, contains a collection, and that
additional class type. Part and PartAssembly classes as above, collection contains objects. One would
and that the path to our database file is expect that fetching a PartAssembly
Simplicity Calls in string variable filename, we can store object – collection and all – would be
Wouldn’t it be nice if all this discus- Part objects into a db4o database with more difficult.
sion of mapping strategies were unnec- the code in Listing 2. Actually, it is only slightly more
essary? As we’ve stated already, this sort This is more like it. Rather than difficult. Although db4o lets us pull
of class structure is easily modeled in clutter our application with SQL code an entire object tree into memory, we
an OO language. It follows that the ideal flanked by assignment statements might not want to. For example, we may
situation would be if that easy modeling that pass object contents into bind want to fetch one or more PartAssembly
were simply extended to the database. variables, we have a single call to a objects from the database, without
Put another way, our object structure’s set() method. Most important: notice fetching the contained collection.
schema is built into the very architec- that we did not have to describe the We can control how “deeply” db4o
ture of our class definitions. Why should structure of a Part object to the db4o reaches into an object tree (when it
we have to create yet another schema database engine; it deduced that infor- retrieves a complex object from the
for the back-end database, and then mation itself, via reflection. database) by adjusting db4o’s “activa-
build a mapping layer to translate data Also notice that db4o invisibly tion depth.” By default, the activation
from one schema to another? Wouldn’t began a transaction for us. The db4o depth is set to 5, which means that
it be nice if we could simply design our engine supports the ACID database retrieving a PartAssembly object would
classes, write our application, and store concepts (atomicity, consistency, isola- also retrieve the collection. (So, fetch-
objects right into the database “as-is”? tion, and durability). We need merely ing a whole PartAssembly would use
With an OO database, we can. close the transaction with a call to code that is virtually identical to the
For the remainder of this article we’ll commit(). Had something gone awry code in Listing 3.) To retrieve only the
demonstrate how to do this by using an during the transaction, we could have PartAssembly – without the compo-
open source database, db4o. Microsoft called abort(), and all operations that nents collection – we can set the global

28 January 2006 •

activation depth to 0, prior to opening mapping file, and so on. However, with OO All the Way AUTHOR BIOs:
the database as follows: db4o, the alteration requires absolutely An object-oriented database makes Rick Grehan is a QA engineer at
nothing beyond the change to the Part a great deal of sense for a database Compuware’s NuMega Labs, where
Db4o.configure().activationDepth(0); class definition (plus any added or application whose content is easily he has worked on Java and .NET
modified methods you would have to modeled in OO fashion. The mapping projects. He is also a contributing edi-
Any database opened after the write in any case): code required to move data between tor for InfoWorld Magazine. His articles
above call would have its activation objects in the application and tables on have appeared in Embedded Systems
depth set to 0. public class Part { the RDBMS is eliminated. Furthermore, Programming, EDN, The Microprocessor
Finally, deleting objects is as private string category; such an application is simply easier to Report, BYTE, Computer Design, and
straightforward as fetching them. If private string name; work with, because there is no concep- other journals. He is also the coauthor of
we wanted to delete the Part object private string manufacturer; tual boundary that must be crossed three books on computer programming.
retrieved in the Listing 3, it requires a private string manufacturerPart- between the object model and the rela-
single line (placed where the ellipses are Number; tional model.
in the listing): private string alternateSupplier; The open-source database engine
. . . db4o made our illustration of these prin- Eric Falsken recently joined the db4o
Database.delete(mb); } ciples all the easier thanks to db4o’s API, team as technical evangelist after
which is both easy to grasp and func- spending a few years working on
followed at some point, of course, with Everything else remains the same. tionally powerful. In one sense, db4o embedded medical devices as a db4o
a commit(). When db4o fetches a Part object from hits a kind of “sweet spot” in that it is not user. He has been a staunch supporter
the database, it will find no content for overly complex, nor under- of Microsoft .NET (much to the chagrin
Changes on the Fly alternateSupplier, and set that field to powered. of his open source–loving co-workers)
Suppose that a change in the null. However, if we then assign a value A complete .NET application that lets and enjoys coming up with new ideas for
application’s requirements demands a to that field and return the object to the you create and manipulate a database elegantly usable software, and mentoring
change in an object’s structure – per- database, the effect will be to turn the identical to what we’ve described in this fellow students of software. You can
haps something as simple as a new “old” Part object into a “new” one (see article is available from www.everylit- read his blog at www.everylittlething.
field. For example, suppose that you Listing 4). The appli- net/blog/.
decided the Part class needed an alter- Thus, after the execution of the code cation was written using Visual Studio
nateSupplier field. in Listing 4, any time we fetch from the 2005, and includes everything you need
With an RDBMS back end, you database the Part object associated with to experiment with the Assembly data-
would have to modify one or more “Desktop Board D945GNT,” it will have base structure. We encourage you to
tables, plus make additions to the an alternateSupplier field of “Dougs explore the application, and discover the
translation code, update the schema Board Outlet.” benefits of “OO all the way.”

Listing 1 Part PartTemplate = new Part (

public class Part { null,
private string category; “Desktop Board D945GNT”,
private string name; null, null);
private string manufacturer;
private string manufacturerPartNumber; // Execute the query
. . . ObjectSet result = Database.get(PartTemp);
// Retrieve the matching object
public class PartAssembly : Part { if(Result.hasNext()) {
private System.Collections.ArrayList components; Part mb = (Part);
. . . // Do something with the Part
} . . .

Listing 2
// Open the ObjectContainer Listing 4
ObjectContainer Database = Db4o.OpenFile(fileName); // Create a Part template object
Part PartTemplate = new Part (
// Create a new Part object null,
Part mb = new Part ( “Motherboard”, “Desktop Board D945GNT”,
“Desktop Board D945Gnt”, null, null, null);
“BOXD945GNT”); // Execute the query
ObjectSet result = Database.get(PartTemp);
// Put it in the database
Database.set(mb); // Retrieve the matching object
if(Result.hasNext()) {
// Commit the transaction and Part mb = (Part);
// close the database
Database.commit(); // Update the alternateSupplier
Database.close(); mb.AlternateSupplier = “Dougs Board Outlet”;

// Return the object to the database

Listing 3 Database.set(mb);
// Create a Part template object } • January 2006


Creating Composite Server Controls

in ASP.NET 2.0 Make new components from old

ne underutilized tech- being developed. Much of this can model is that our control inherits
nique for maximizing of course be copied and pasted from System.Web.UI.WebControls.
code reuse and increas- from one application to another, CompositeControl (see Listing 1).
ing developer produc- but when changes occur, these In previous versions of the .NET
tivity is the creation and utilization changes must then be made in Framework, you inherited from
of ASP.NET Server controls. Even multiple applications. An example Control and had to implement
when the problem domain is well of this type of change would be the INamingContainer interface.
known and understood, each to an address for a company that These steps, along with other
new project has many developers has recently gone international functionality, are now taken care
starting at square one, dragging and now must start capturing the of by the CompositeControl base
and dropping the common Visual country where their customers class. The CompositeControl class
Studio.NET controls onto a blank are located. By utilizing a server also has an associated control
form and having to manually control, the display and client-side designer that ensures that child
repeat the same processes that logic to handle this new data can controls are displayed on the
other developers in the company be coded once, with developers design surface.
have had to perform in the past. now focusing on updating the busi- You will also notice several attri-
Server controls are an in-depth ness logic. butes attached to the class defini-
topic and it would take an entire The server control in our tion. These help define various
book to do the subject justice. example creates a simple user characteristics of our control:
In this article I will explain the interface (UI) for entering phone • AspNetHostingPermission: This
basics of how to create a type of numbers. It is composed of a is required to ensure that code
server control called a Composite Label control, a TextBox control, that links to the control has the
BY WES WEEKS control, and to highlight some of and two validator controls: one is appropriate security permissions
the differences between ASP.NET a RequiredFieldValidator and the • DefaultProperty: Specifies the
1.x and ASP.NET 2.0 server con- other is a RegularExpressionValida property to highlight in the
trols. (Source code is available by tor. One of the advantages of using property browser when the page
viewing this article online in the composite controls is that you developer selects the control on
.NETDJ archives, http://dotnet. can utilize the ASP.NET controls’ the design surface, built-in behavior to minimize the • ToolboxData: Used to specify
[Vol: 4, iss: 1].) amount of code you have to write. the format string for the design
For example, you will be able to environment created when the
The Case for Server Controls utilize the validator controls to per- control is added to a page
Most businesses have certain form their native functions without
sets or types of information that having to write any control-specific Define Composite Control
are ubiquitous to most of the code. Properties
applications being developed. The next step in our compos-
Addresses, phone numbers, and Defining a Composite Control ite control is to define the public
customer names are just a few One of the first things you properties that will be accessible
examples of common input col- will probably notice if you are via the property browser in Visual
lections that are often duplicated familiar with developing server Studio.NET. Most of the proper-
each time a new application is controls under the ASP.NET 1.x ties are a direct pass through to

30 January 2006 •

“By utilizing a server control, the display and
Wes Weeks is president and CEO

client-side logic to handle this new data can be

of AgileWise, a software develop-
ment and consulting firm based

coded once, with developers now focusing on

in Topeka, KS. Wes has extensive
experience in object-oriented

updating the business logic”

technologies, enterprise application
architecture, and service-oriented
architecture design and develop-
ment. He is currently consulting for
properties inherent of the controls the Style property of the controls In this example we have set a Security Benefit, an organization
that make up our composite control within the composite control specific style for the Label by set- named one of CIO Magazine’s
example. The code snippet in Listing didn’t work as expected, and though ting the LabelStyle property in the “Agile 100” in 2004 that has suc-
2 demonstrates this pass-through you would see the Style settings property grid. This was translated cessfully employed numerous Agile
technique. displayed in the property grid, set- into the LableStyle element as a methods and processes.
One of the nice features of ASP. ting them did not translate into sub element of the phone control
NET 2.0 is the ability to assign a run-time functionality. One of the itself. 4
group name to a set of validators to reasons for this is that the ASPX
ensure that validation occurs only for page didn’t have a location to store Creating Custom Functionality
controls in the specified group. This the values of the style settings. Although creating a composite
enables you to have multiple sepa- This has been remedied in 2.0 and control in and of itself provides a
rately-validated forms on a single multiple style properties can be considerable benefit in terms of
page. In our property example above, exposed and recorded in the ASPX code reuse and faster development,
the validation group is assigned to page to allow styles to easily be set it is always nice to provide some
both of our validation controls dur- at design time. Our property for additional functionality to enhance
ing the set operation. It doesn’t mat- each style sheet resembles any of the control’s usefulness. For our
ter which validator control’s property the other properties we have cre- example we are going to provide the
we returned for the ValidationGroup ated. The way ASP.NET handles the ability for our control to automati-
get operation and our arbitrary Style properties can be viewed by cally put the phone number that
choice was the value from the looking at the HTML view in Visual is entered into a standard format.
phoneRequired control. Studio.NET. In order to accomplish this, we are
There are also several attributes going to render some JavaScript on
on the property worth mentioning: <cc1:PhoneControl the client that will be called when
• Bindable: Indicates that the prop- ID=”PhoneControl1” our control loses focus to provide
erty supports data binding runat=”server” LabelText=”Phone” the formatting (see Listing 4).
• Category: Determines which cat- FormatMessage=”Invalid Phone The call to this method to render
egory this property will be associ- Number” RequiredMessage=”Phone the JavaScript occurs during the
ated with on the PropertyGrid is Required” > OnPreRender event. The neces-
• Description: Tells the developer <LabelStyle sary control attribute to call the
who is using the control what the BackColor=”Red” ForeColor=”White” JavaScript function when the text-
property does /> box loses focus was rendered in our
</cc1:PhoneControl> CreateChildControls() method.
Adding the Controls to the
Controls Collection Changes Between Developing Server Controls
The next step in the process
Under ASP.NET 1.x and 2.0
is to add the controls that make
up our composite control to the There were several changes to the ASP.NET server control model that improve upon
Controls collection of the base the server control object model and to make control development easier. The list below
CompositeControls class. This is a highlights some of the most notable changes:
fairly straightforward process and • ControlState: This is an alternative way for developers to persist control properties
simply involves initializing our in the page without using ViewState. The advantage is that while ViewState can be
controls, setting any default prop- turned off at the page level by the developer, ControlState can’t, so the control devel-
erties, and then utilizing the Add oper can be assured that data that has to be persisted for proper control function can’t
method to add them to the con- be turned off
trols collection by overriding the • ValidationGroup: Allows a group of controls to be validated together so that the devel-
CreateChildControls() method (see oper can enforce validation on a subset of controls on a page
Listing 3). • CompositeControl: A new class that can be inherited from by control developers that
eases the development and creation of composite server controls
Define Style Properties • Styles: Working with CSS Styles has been made easier with the ability to expose Style
Defining and using styles under properties into the property grid and have those changes created and stored in the
ASP.NET 1.x took a considerable ASPX page at design time
amount of work. Simply exposing • January 2006


“Spending the little bit of extra time to develop a

custom control can result in productivity gains for
developers and ease making global changes to the
front end by having a single control to maintain”
One thing to note for those consistent in any page that may Start the Web project and enter
who have developed server con- use the control. This is also the in the area code and phone number
trols under the 1.x paradigm is location of where we render any without any symbols or format-
the ClientScript property of the Style attributes that are set at ting. Notice how the number neatly
Page object. The ClientScript design time by the page developer formats itself when you move off of
property is an object of type (see Listing 5). it provided it has either 7 or 10 dig-
ClientScriptManager and should its. If it doesn’t, formatting doesn’t
be utilized instead of the Page. Building and Using the Control occur and the form won’t submit
RegisterClientScriptBlock() method The last step in the process is due to our regular expression vali-
that has been deprecated. It has a to add our created control to the dator. If you have set the Required
few new arguments, including ask- toolbox so that we can add it to property to true, the form will pre-
ing for a type in addition to the key our page by using drag and drop. vent you from submitting a blank
field to assist in matching up the The easiest way to do this is to number as well.
client script to the control, as well open the toolbox panel, right-
as the ability to have the method click on add/remove items, and Summary
automatically output the script tags then browse to the bin directory This fairly simple example dem-
by setting the addScriptTags argu- containing the assembly for the onstrates how easy it is to begin
ment to true, which is shown in this server control. This will add our creating custom server controls that
example. control to the toolbox and from can be used to provide common
there it can be added to a Web functionality for your applications.
Override the Render Method form like any of the built-in con- It demonstrates how to create a
The last step in the control trols. After adding a control to the composite control, apply styles, and
creation is to override the render toolbox we can now create a Web add custom functionality. Spending
method to provide the formatting project. With the Web project the little bit of extra time to develop
for our control on the page. In this newly created, drag and drop the a custom control can result in pro-
example we render the multiple phone control from the toolbox to ductivity gains for developers and
controls that make up our compos- a Web form. Let’s also add a valida- ease making global changes to the
ite control within a table to be sure tion summary control and a submit front end by having a single control
the way the control gets rendered is button. to maintain.

Listing 1 Listing 2
[AspNetHostingPermission(SecurityAction. [Bindable(true),
LinkDemand, Category(“Behavior”),
Level = AspNetHostingPermissionLevel.Minimal), DefaultValue(“”),
DefaultProperty(“Text”), Description(“Validation Group the control
ToolboxData(“<{0}:PhoneControl runat=\”server\”> belongs to”)]
</{0}:PhoneControl>”)] public string ValidationGroup
public class PhoneControl : CompositeControl {
{ get
private Label phoneLabel; {
private TextBox phoneTextBox; EnsureChildControls();
private RequiredFieldValidator phoneRequired; return phoneRequired.ValidationGroup;
private RegularExpressionValidator phoneRe- }
gex; set
private Style labelStyle; {
private Style phoneStyle; EnsureChildControls();

32 January 2006 •

phoneRequired.ValidationGroup = value; substr(0,3) + \”) \” + text.substr(3,3) + \”-\” +
phoneRegex.ValidationGroup = value; text.substr(6,4);\r\n”);
} sb.Append(“\t}\r\n”);
} sb.Append(“\tif(text.length == 7){\r\n”);
sb.Append(“\t\t phoneTextBox.value = text.sub-
str(0,3) + \”-\” + text.substr(3,4);\r\n”);
Listing 3
protected override void CreateChildControls()
string script = sb.ToString();

phoneLabel = new Label(); GetType(), “formatPhone”, script, true);

phoneLabel.ID = “phoneLabel”; }

Controls.Add(phoneLabel); }

phoneTextBox = new TextBox();

Listing 5
phoneTextBox.ID = “phoneText”;
protected override void Render(HtmlTextWriter writer)
phoneTextBox.Attributes.Add(“onblur”, {
“formatPhone(this)”); AddAttributesToRender(writer);

phoneRequired = new RequiredFieldValidator(); Cellpadding, “1”, false);
phoneRequired.ID = “phoneRequired”; writer.AddAttribute(HtmlTextWriterAttribute.Border,
phoneRequired.ControlToValidate = phoneTextBox.ID; “0”, false);
phoneRequired.Text = “*”; writer.RenderBeginTag(HtmlTextWriterTag.Table);

if (labelStyle != null)
phoneRegex = new RegularExpressionValidator(); {
phoneRegex.ID = “phoneRegex”; phoneLabel.ApplyStyle(labelStyle);
phoneRegex.ControlToValidate = phoneTextBox.ID; }
phoneRegex.Text = “*”;
phoneRegex.ValidationExpression = @”(((\(\d{3}\) if (phoneStyle != null)
?)|(\d{3}-))?\d{3}-\d{4})|\d{10}|\d{7}”; {
Controls.Add(phoneRegex); phoneTextBox.ApplyStyle(phoneStyle);
} }

Listing 4
private void RenderJavaScript()
if(!Page.ClientScript. IsClientScriptBlockRegistered(th
is.GetType(), “formatPhone”)
{ writer.RenderEndTag();
StringBuilder sb = new StringBuilder(); writer.RenderBeginTag(HtmlTextWriterTag.Td);
sb.Append(“function formatPhone(phoneTextBox){\r\ phoneTextBox.RenderControl(writer);
n”); phoneRequired.RenderControl(writer);
sb.Append(“\tvar text = phoneTextBox.value;\r\n”); phoneRegex.RenderControl(writer);
sb.Append(“\ttext = text.replace(/\\D+/g,\”\”);\r\ writer.RenderEndTag();
n”); writer.RenderEndTag();
sb.Append(“\tif(text.length == 10){\r\n”); writer.RenderEndTag();
sb.Append(“\t\t phoneTextBox.value = \”(\” + text. } • January 2006


When Design and

Development First Met
Love the skin you’re in

id you know that the termi- developers who may be purists, and

d nology known as skinning

has been around for quite
some time, but never in the
who are often left behind with less
sophisticated but visually appealing
applications getting the first look from
hands of mainstream designers and the end user. This has changed in
Web developers in the content man- the last few years. So focused are we
agement space? Simple skinning or on reaching our audience that many
skin themes, which are more familiar, companies are investing as much
started back in the days of Windows time in overhauling the look and feel
when you could change the color/ UI as they are in developing their
background of your desktop. application to gain acceptance from
From there we have seen an a broad audience of often inexperi-
almost cult-like audience of avid enced but visually spoiled users. This
designers who wanted to totally trans- trend is simply part of the cycle of
form their desktops, programs, icons, technology development, where cut-
you name it – if it could be changed, ting edge becomes mainstream and
someone wants to do it. These are the the bar of expectations of Web-savvy
things that make us push design to users is raised another notch.
the boundaries of being different. that the designer’s perceived value With the success of DotNetNuke,
Since then we’ve seen applications in the eye of the developer has been a Web Application Framework, the
(such as WinAmp, ICQ, and others one of very little importance, even genuine effort to involve designers has
that have a global-reaching user base) of nuisance until recent times. Until seen a powerful portal solution that a
create the start of changing the look just a few short years ago we had development company can encom-
and feel of your application. WinAmp seen elements of themes and skin- pass in their mix of business solutions.
began its life in May 1997 (http:// ning, but only in piecemeal and small A company’s provision of both devel- with segments, and never as a holistic opment and design work can marry
their Web site’s existence (based on approach to a solution being offered their skills and produce a Web site
a WhoIs check showing that back to the public as we have today. that is visually fantastic and that can
in December 1999) helping drive perform to their expectations – but
its popularity by providing skinning Visual Appeal Helps Sell a we now have another dimension: the
BY NINA MEIERS capabilities to let all users choose Great Developer’s Code excited end user who feels empowered
their own look and feel of the inter- In a short period of time, with by his or her ability to manage the
face while listening to mp3s. the emergence in abundance of very Web site, which in turn brings about
We almost accepted that it was sophisticated Content Management more business opportunities.
purely for desktop-based applications, Systems (CMS), the actual site behav-
until the evolution of DIY Portals in ior and programming functionality Smart Developers Setting
the early years of the new millennium has improved. The downside has been the New Standards
provided a range of preconfigured that a total separation of the process This trend has engendered an
themes you could choose to display and the visual design has fallen well evolvement of smart developers
on a Web site. However, most of these short. So many tremendously power- – who understand that pitching their
were preconfigured, rather crude, and ful applications simply get bypassed solution to their prospective clients,
rigid representations of templates that because they don’t appeal to the end employers and existing clients is not
were designed in-house by a team user. just about telling them how good a
of developers probably working with Whether we like it or not, sizzle- solution is, but how good it will look.
designers. and-wow factor helps sell an idea Therefore, part of the process can
In the past there were also limita- or product to the decision makers, involve a designer to complete the
tions bound by technology and that and something that looks great helps cycle.
were most likely the lack of involve- acceptance and adoption of a prod- The skinning engine architecture
ment with graphic designers. It seems uct. This causes frustration among of the DotNetNuke Web Application

34 January 2006 •

u c to r!y
introipd offer
cr tion

A TRULY INDEPENDENT Here’s what you’ll find in

VOICE IN THE WORLD OF .NET every issue of .netdj:
.NET Developer’s Journal is the leading

independent monthly publication targeted at .NET Security Watch

Mobile .NET
developers, particularly advanced developers. It brings
.NET Trends
.NET developers everything they need to know in order
Tech Tips
to create great software.
Standards Watch
Business Alerts
monthly, .NET
.NET News
Book and Software
Journal covers Announcements

everything of interest to .NET Developer’s Journal is for .NET

developers of all levels, especially those “in
developers working with the trenches” creating .NET code on a daily
Microsoft .NET technolo- • For beginners:
Each issue contains step-by-step tutorials.
gies – all from a • For intermediate developers:
There are more advanced articles.
completely independ-
• For advanced .NET developers:
In-depth technical articles and columns
ent and nonbiased per-
written by acknowledged .NET experts.
spective. Articles are care-

Regardless of their experience level, .NET
fully selected for their prime Developer’s Journal assumes that everyone
reading it shares a common desire to under-
technical content – technical stand as much about .NET – and the busi-
ness forces shaping it – as possible. Our aim
details aren’t watered down with or Call is to help bring our reader-developers closer

lots of needless opinion and com-

mentary. Apart from the technical content, expert ana-

1 888 303-5282 and closer to that goal with each and every
new issue!

lysts and software industry commentators keep devel-

opers and their managers abreast of the business

forces influencing .NET’s rapid development. SAVE16% ANNUAL


OFF $83.88
Wholly independent of both Microsoft Corporation

and the other main players now shaping the course of


.NET and Web services, .NET Developer’s Journal

represents a constant, neutral, expert voice on the $

state of .NET today – the good, the bad, and the
ugly…no exceptions. Get 12 issues of .NETDJ
for only $6999! $13.89
Framework has been helping to push DotNetNuke Skinning: ther enhancements/customizations
DotNetNuke to areas most other CM Simply Powerful without the requirement of coding
Systems would only dream of. With Skinning in its basic interpreta- it into the HTML. Two examples are
its unique open source but tightly tion allows you to customize and the [CURRENTDATE] and [SEARCH]
knit community of thousands of change the look and feel of the Web tokens.
contributors, over the last two years site without disturbing the code that An example using the
it has evolved to be one of the most runs it. This completely changes the [CURRENTDATE] skinobject/token
advanced online solutions available. dynamics of how it will look next allows us to put the current date into
When looking for total flex- time it needs to be updated, and in the page and from the server, will
ibility and ease of management, fact has changed how the business display the date in a standard format.
DotNetNuke provides a taste of suc- of selling Web sites to customers will However as a designer, I can choose
cess for all parties involved. That’s be carried out in years to come. One to modify several elements of it. I can
not saying that you can simply pick of the key elements of DotNetNuke is change the font type using classes,
up and understand it in one day. Sure the power of the skinobjects/tokens. or I can change the text displayed to
there’s a learning curve, but overall, Designers can work in either show different date formats such as
once you understand the methodol- HTML or ASCX (control) mode to dd/mm/yyyy, mm/yyyy, etc.
ogy, it’s almost intuitive as to how create their skins. Skins are packaged An example using the [SEARCH]
things are done. together using the images, CSS file, skinobject/token allows me to dis-
and XML file, and they are zipped play text, which is customizable and
Why the Excitement About ready for installation. When logged overrides the default formats, so that
the Word Skinning, Themes, in with appropriate permissions, the I can use words that work within
and Designing? administrator can then map to their the requirements from the client.
The free-form mind of a designer local skin folder, add the skin zip file Furthermore, I can use an image
has very few limitations when design- to the window, and upload the skin. instead of a word when displaying
ing a DotNetNuke Web site, once a The skinning engine takes over the search function. All is controlled
designer understands how it works. and parses the information, and if and managed by the designer, with-
The wow factor starts immediately, so the HTML method of skinning is in out interruptions to the functionality
a developer who initially appreciated use, it integrates information in the of the code.
the value of working with DotNetNuke XML file and creates the ASCX con- Skinobjects and tokens are still
as a solution no longer needs to be trol file, which is then responsible very new in understanding and
apologetic about how it looks. for outputting the data to the ASPX adoption, and as more designers
Developers who work with design- page. That’s the simple explanation, and developers work together, more
ers during a project can often pick and the skinning engine is truly one complex skinobjects will play an
up simple techniques, usually using of the most remarkable aspects of important role in managing the look
CSS, which can be adapted to the next DotNetNuke. and feel of site.
project. A designer who spends some Some designers who under- Containers are the elements
time learning this DotNetNuke will stand the programming side of that hold the module function.
certainly appreciate the flexibility pro- DotNetNuke may prefer to use the For example, Print, Syndicate, and
vided, and wil be able to contribute ASCX method of skinning, which Minimize options are held with
valuable information to a developer to eliminates the use of the XML file another element called a container,
produce a seamlessly integrated Web and allows you to define all functions and when logged in to edit the site,
site. of the skin within the ASCX file itself. module functions known as actions
Having said that, it is important Some of the key words a are then selected from a drop-down
for designers to stretch themselves DotNetNuke designer/developer will menu. Containers are both func-
somewhat and learn a few basic prin- hear are skinobjects, tokens, con- tional and decorative if required, and
ciples. Although DotNetNuke provides tainers, panes, CSS, Solpart Menu, while always visible when logged in
free-form designing, it is in fact a rigid XML, ASCX, HTML, and third-party as administrator, they can be com-
framework that must be adhered to controls, just to name a few. These pletely hidden when logged out.
when looking at providing a com- make up the everyday language of Panes must be included in every
plete workable solution. If a designer the world of skinning. skin. They are the locations that the
can truly embrace a few developer Skinobjects are programmed ele- modules are applied to when you are
concepts, he or she can master the ments of code that interact with skin adding content to your site. They sit
depth of skinning possibilities that in the form of code-behind controls as either <div> tags or as part of the
DotNetNuke provides. that allow a designer to provide fur- <td> tag. At the very least you need

“So many tremendously powerful applications simply

get bypassed because they don’t appeal
to the end user”

36 January 2006 •

one element called the ContentPane to errors. However, developers who don’t It’s a matter of personal preference AUTHOR BIO:
make any skin work. know HTML but who know code might to choose your ideal design method, Nina Meiers is a DotNetNuke core
Solpart Menu is the default not pick this up, and if a designer but I’ve found it easier to establish team member who works closely
menu that is packaged with every hasn’t learned some of the functional- what changes your client will prob- with developers and has been
DotNetNuke installation, and much ity of DotNetNuke, he or she might ably want to make and design the skin in the UI, skinning, and graphics
time is spent customizing the menu. It not recognize this as being an HTML accordingly, so they can either replace space for more than eight years.
is perhaps the most challenging aspect error either until learning more about images, or quickly find the code in With close to 16,000 registered
of DotNetNuke to learn when integrat- the behavior of DotNetNuke modules well-commented CSS code and make users on her site, along with
ing Web sites with a design. within an HTML holder. changes themselves. nearly 80,000 downloads of her
CSS is used thoroughly through- free skins, Nina has worked with
out the DotNetNuke Web Application Skinning – The Scale of Summary many companies, corporations,
Framework, and when developers and Talent Required The following points summarize the and indviduals to help them
designers collaborate, particularly with The five golden skills needed merits of the DotNetNuke skinning tool: change the look and feel of their
custom modules, it’s perhaps one of to create a fantastic and workable • DotNetNuke skinning is a powerful Web sites. She is currently writing
the most important elements to work DotNetNuke Web site are: tool that combines the talents of both a book on DotNetNuke skinning
with when designing your DotNetNuke • Good DotNetNuke skills developers and designers. and design and details of its
Web site. • Strong CSS skills • Its ability to totally separate code release will be publicized shortly.
XML is the conduit that the skin- • Strong HTML skills and UI management mean that each You can visit one of Nina’s Web
ning engine reads when uploading an • Good XML Skills party can work independently with sites at
HTML skin, and information in the • Good graphical skills confidence, knowing that the integ-
XML file is then parsed to the ASCX file. rity of his or her work is not going to 4
ASCX skinning requires some pro- While many may think you need to be compromised.
gramming knowledge to implement be a great graphical designer to make • Developers who embrace the knowl-
successfully, and it is often the pre- a brilliant DotNetNuke skin, it pales to edge of designers when developing
ferred choice of experienced designers. insignificance if it’s totally unusable. modules and further enhance their
You don’t need the HTML or XML files Understanding your working environ- own product by allowing seamless,
to skin using the ASCX method. ment is paramount. There are so many attractive integration of their mod-
HTML skinning is where all new- very clever options available for a ules into a DotNetNuke site will reap
comers to DotNetNuke should start designer who knows how DotNetNuke the rewards in the future, because the
until they are familiar with how it works, and working with it not only expectation of users these days is that
works. The skinning engine is more for- gives you a higher level of appreciation, it also must look good.
giving of errors within the HTML file, but also helps you to push your design • The skinning engine, although always
and for those who require more back- ideas further. in development and improvement,
ward compatibility, HTML is the way is well designed and extremely
to go. Which Is Best? advanced in its offerings for devel-
There are two distinct branches opers and designers alike to further
What It Takes to Skin a Web Site of opinion in the DotNetNuke com- enhance by developing skinobjects
Mastering the art of skinning munity. Some believe that the best to increase functionality, but keep it
requires developing a few strong areas way to develop is the HTML method, dynamic.
before tackling huge projects, and with the files always being available • To start skinning your DotNetNuke
many newcomers are disappointed for updating and those with even the Web site, there is documentation
with their results when taking existing lowest level of experience can make already written, but simply opening
static templates of complex-looking changes. However, by offering that the default skins in the install shows
sites and then trying to turn them into solution to clients, it doesn’t always you a zipped file ready to update, an
a complex-looking DotNetNuke skin. go as planned because many of the ASCX example, an HTML and XML
Strong HTML skills are a must to create changes that their clients wish to make example, and it’s an excellent starting
complex skins. Many people blame the involve understanding XML, which can point.
difficulty of working with DotNetNuke be more complicated than HTML itself • Start with a simple project and get
skinning when in fact, many of the and beyond the realm of most novice the feel of how it works, and enjoy the
problems associated with the way designers. This relates more to the small successes first before embark-
the page displays are due to a lack of menu functionality where advanced ing on larger, more complex tasks.
understanding of how HTML works in knowledge of the CSS elements and • If integrating custom written solu-
the first place. property behavior are required. tions for clients, enhance the visual
Pages that lose their formatting Most experienced developers/ appeal by working with a skinning
when adding content would in fact lose designers tend to work in the most effi- specialist who understands the audi-
their structures if they were in a static cient method, which is using the ASCX ence, the platform, and the developer.
HTML page. Sometimes the nesting of controls where all of your functions • Most of all, spend time becom-
tables and how modules behave with and code reside within the skinob- ing familiar with DotNetNuke. Like
tables embedded in a page may have a ject code, and the page can be either any other application, it needs and
slight influence, but overall, the most worked on locally and refreshed or deserves the time to become familiar
common mistakes when creating a simply using FTP, uploaded to the skins with it to reap the benefits that it will
DotNetNuke skin are common HTML folder. give you. • January 2006

Industry Analysis

The Shape of i -Technology to Come

his is traditionally the time of ROI and the business case for backward to the 3270 and forms
of year for SYS-CON Media’s innovation, not just innovation for mode. That was good enough for a
roundup of i-Technology innovation’s sake. while, but not anymore.
predictions from around As ever, please don’t hesitate send 2. LAMP in the enterprise. If you
the Web and the year’s harvest of us your own thoughts. “None of us follow my portfolio company,
thoughts and viewpoints. According is as smart as all of us,” they say, a ActiveGrid, you’ll find one of the
to our worldwide network of software philosophy that has even spawned a leaders of the J2EE app server
development activists, evangelists, book (The Wisdom of Crowds: Why the market now offering a far easier-
and executives, 2006 promises to be Many Are Smarter Than the Few and to-build and less-expensive-to-
a vintage year for software develop- How Collective Wisdom Shapes Busi- deploy platform.
ment… ness, Economies, Societies and Nations 3. Virtualization. With three strong
Take Microsoft, for example: A new by James Surowiecki,). We will publish virtualization platforms (VMWare,
client OS is on the way, Microsoft Vista, a roundup of readers’ predictions in Microsoft Virtual Server, and
due late in 2006, giving rise to the the February issue of Java Developer’s XenSource) now available, there
obvious question: Will the new cool Journal. will be more and more software
3D user interface be enough to move Let’s begin this year’s roundup products built not on traditional
the user to upgrade? We’ll see. Maybe with the predictions for 2006 of hardware/software platforms but
the new built-in security, performance Mitchell Kertzman, now at Hummer on virtualized platforms. Check
features, and integrated search will be Winblad Venture Partners but still out Akimbi Systems, which
enough to convince users – after all, famous for having been the founder provides a very exciting applica-
why go to the Web if built-in Web-en- and CEO of Powersoft, which merged tion for QA and testing in the
abled services and integrated informa- with Sybase in February 1995. When enterprise.
tion search allow the Web to come to someone with over 30 years of expe- 4. 2006 will be the year of acceptance
you? rience as a CEO of public and private of the importance of roles in the
Or consider the world of PDA software companies tips LAMP, for world of identity management and
devices. Everyone is looking for the example, it lends a certain credence provisioning. Bridgestream is the
next killer Palm or BlackBerry, but to an already strong trend that we leader in
BYJEREMY GEELAN are they looking in the right direction have sought to cover in SYS-CON role management integrating with
for the next killer PDA? What about Media’s various publications such the leaders in identity manage-
unexpected places – for example, as LinuxWorld Magazine and over at ment, directory services, and pro-
Nintendo? Check out the new visioning.
Nintendo DS: Could you imagine it 5. The two trends that will not be
running Pocket PC or Palm OS? That MITCHELL KERTZMAN new for 2006 but that will con-
would make a very cool gadget. What AJAX, LAMP, Virtualization, tinue their growth are Software
about the iPod? Have you seen the SaaS, Open Source as a Service (SaaS) or on-demand
new iTunes-enabled Cingular Phone? software and open source, which
It could be closer than you think. Since I’m in venture capital now, continues to find acceptance in
On the pages that follow you’ll find I try to put my (and others’) money the enterprise.
the collected wisdom of some of the where my mouth is, so my predic-
most acute prognosticators in the tions will tend to match up with my Our next set of predictions comes
industry. As always with JDJ and portfolio. from Jim Milbery, CTO for Chicago
SYS-CON Media, we don’t ask pun- In no particular order: Growth Partners in Chicago with
dits and sideline commentators but 1. Rich application interfaces, 30-plus companies under his wing
activists, folks whose connection including (but not exclusively) (.NET, Java, ColdFusion, Python
with software development and/or AJAX. Enterprise developers/IT – “you name it,” as he says). He also
the software industry is daily, intense, managers have finally realized that acts as the “virtual CTO” for a num-
and driven by real-world concerns the browser interface was a step ber of companies in his portfolio.

38 January 2006 •

JIM MILBERY revolution instead of trying to close noises. AUTHOR BIO:
SANs, AJAX, Web 2.0, it down. You can’t push back the tide. 5. Support for RSS in Microsoft Vista Jeremy Geelan is group
Blog consolidation, InfoSec The BBC is going to be launching and Internet Explorer 7 will be publisher of SYS-CON Media
BBC2 as the first broadband televi- indistinguishable from Windows and is responsible for the
1. Data storage: The proliferation of blogs sion channel in 2006. 95’s Active Channels, following the development of new titles
and the raw size of XML documents 3. Google shares fall or even crash. company’s removal of new features and technology portals for
(and everything is XML these days) are Everything that goes up has to come due to security concerns. There will the firm. He regularly represents
going to drive us to a new emphasis on down and, contrary to popular be massive growth in enterprise-ori- SYS-CON at conferences
storage (SANs in particular). belief, they aren’t the biggest player ented knowledge management sys- and trade shows, speaking to
2. AJAX everywhere: IE gets new life out on the Internet and people will start tems based on RSS and Atom. There technology audiences both in
of the proliferation of AJAX. More distrusting them as Microsoft and will be a new generation of RSS/Atom North America and overseas.
high-profile sites are going to adopt Yahoo! crank up their offerings. aggregators exploiting data published
AJAX as a means of extending the 4. In fear of Microsoft Vista (and AJAX), using XHTML microformats and 4
life of the browser in the near term. Adobe will offer all Flash develop- Structured Blogging.
We may even see the return of some ment tools for free, which will result 6. Traditional search engines will
application-development tools in a major surge in adoption. increasingly be augmented with
around AJAX (something more than 5. IE7 will probably more than likely metadata-based directed query capa-
just component libraries). eclipse Firefox again. bilities, initially driven by keyword
3. Dashboard apps: Even with the prolif- tagging, but increasingly with refer-
eration of AJAX we are going to see a From Alan Williamson we move to ence to “Semantic Technologies.”
serious rise in client-specific apps that another uber geek, Danny Ayers – tech- Social networks will become a factor.
are based on Web 2.0 technologies nical author, Semantic Web developer 7. A new market in commodity pack-
– think iTunes. and blogger, who “got rather carried ages combining data storage and
4. Blogging acid-reflux: The massive away,” as he put it. But his 10 predic- protocol support will begin to appear.
interest in blogging continues to rise, tions all have an uncanny ring of truth These packages will allow plug-in
but reliance and confidence in indi- to them. scalability and cross-system synchro-
vidual blogs sags; high-profile blogs nization, with implementations being
that are industry-specific begin to DANNY AYERS built variously on Grid architectures,
dominate and provide a bit of “edit- SOA, REST, Single Sign-On, Atom Stores, general XML stores, and
ing” to the process. SemWeb, iComm, RDF triplestores. Google will release a
5. William Strunk Jr. rolls over in his Structured Blogging boxed Data Appliance Solution, with
grave: The illustrious author of The 1. A consortium will identify and replication on their own servers.
Elements of Style officially rolls over in strongly promote a subset of the 8. Service mash-ups will become
his grave. I thought that basic writing WS-* stack, leading to an accelera- increasingly sophisticated, with
skills were bad as seen in e-mail docu- tion in the growth of SOA. Meanwhile microcompanies able to compete
ments, but blogging takes things to a there will be a significant increase in head-on with the big companies’
whole new level of poor grammar and deployment of purely REST-based portals.
punctuation. services. HTTP will be sexy again. 9. While advertising will become more
6. Information security: We start to get 2. IBM, Sun, and Oracle will announce a sophisticated in its targeting, user
serious about protecting applications joint identity management initiative, attention tracking will lead to other
during the coding process, not just as with Google’s single sign-on being the revenue sources becoming more
an afterthought. leading competitor. attractive, and the feedback loop
3. The rebranding of the Semantic Web from online opinions to product
Next up is Alan Williamson, tech- as “Semantic Technologies” and development in the real world will
nology evangelist for SpikeSource and “Web of Data” will enable previously begin to close. Market research will
distinguished former editor-in-chief dismissive pundits to hype it as the begin to counterbalance search
of JDJ, as well as chief architect of Next Big Thing. There will be real engine optimization as the road to
BlueDragon. growth in these areas, but not as yet fortunes.
meteoric. Yahoo! will reveal its answer 10. A clear divide will appear between
ALAN WILLIAMSON to Google Base, built using Semantic companies that approach the Web
Java, BitTorrent, Googlecrash, Web technologies. Nokia will join in a participatory fashion and those
Adobe, IE VoIP to the Semantic Web. that produce a 21st century net-
4. Mobile devices will become still more worked version of the shrink-wrap
Here are my modest predictions for sophisticated and more ubiquitous. product. The continuing growth of
2006: There will be a growth in “base sta- open source will drive the compa-
1. Java has been in the dark for the tion” software and smarter notifica- nies in the latter group to attempt
past few years; its time to come back tion and synchronization between increasingly desperate measures
around again is here. Sun has some the desktop/LAN and mobile device. to counter the decline in their
interesting initiatives in the pipeline. Apple will explode onto the mobile revenue. More ridiculous patents
2. The movie industry will wake up to phone market with their iComm, will be granted, existing ones will
BitTorrent (and the likes) and actu- which will include a new user inter- be stretched to the limit in courts.
ally figure out a way to utilize this face paradigm and make Star Trek Lawyers will make lots of money. • January 2006

Industry Analysis
J.P. Morgenthal, managing partner being recognized as a critical Server Message Bus” (CSMB): a
for the IT consultancy Avorcor and enterprise asset. It’s now being set of client/server applications
the author of Enterprise Information managed properly and leveraged can talk to each other using open
Integration: A Pragmatic Approach, for its properties for automation. source messaging and an enter-
is as usual very forthright in his 7. Semantic technologies: People prise service bus. Note: Client/
foresight. and organizations are finally server applications can have
starting to see the value in being more than two tiers, e.g., RMI cli-
J.P. MORGENTHAL able to describe data in context ent, RMI Server and DBMS.
VPMNs, AJAX, VoIP Phones, and defining the relationships 6. Programming will become the
SaaS, Semantic Technologies between data. Semantic tech- trade of the younger generation.
nologies enhance and extend Middle-age programmers will be
1. Private mail networks: With peo- the basic power realized by rela- leaving the coding arena and
ple getting slammed I believe tional database technologies to moving to business analysis and
we will see the rise of VPMN data anywhere in the world. management. You can’t beat a
(Virtual Private Mail Networks). 25-year-old Indian program-
Essentially, these are analogous JDJ’s enterprise editor, Yakov Fain, mer who’s ready to join any
to VPNs, allowing private net- has 10 predictions, several of them project tomorrow (in any place
work traffic to run over the pub- directly involving Java. on Earth), sharing a room in
lic backbone. They use common so-called guest apartment. The
SMTP protocols to deliver mail, YAKOV FAIN code quality of such a program-
but unless you have permission Java 5.1, AJAX, “CSMB,” mer may not be as good as was
to send mail to the recipient the Outsourcing, Yahoo! expected by the employer, but
mail will be rejected. this will be a little secret for
2. AJAX: We will see the rise of 1. Enterprises will finally start using some time, and smart kids will
even stronger support for more Java 5. The sooner the 5.1 version have enough time to learn how
powerful portable client-based is released the better. to program on the job.
applications based on Web pro- 2. AJAX hype will calm down. AJAX 7. A number of CIOs will come out
tocols. is an interesting technology and of the closet and publicly admit
3. Composite applications: With the will become one of many tech- that the real cost of outsourced
rise of SOA and BPM, it’s going niques used in Web application projects is high, because for
to get even easier to develop development. Nothing more. every two young Indian program-
applications that require less 3. Fat clients will be more widely mers, you need a local business
low-level coding skills and used in distributed enterprise analyst who will write super-
that are more flexible and can applications. Java still has a detailed functional specifications
respond faster to changes in chance to be used in this area, and validate their work. But
business. if someone will create an IDE outsourcing is here to stay (at
4. VoIP phones: Advancements and with an easy-to-use and powerful least in the US) and not because
growth in high bandwidth wire- Swing GUI designer. JDeveloper overseas programmers charge
less networking means that wire- and NetBeans are leading here. less, but because just finding
less devices will be IP address- Adobe (formerly Macromedia) local programmers will become a
able, which means that the next tools will become more and more difficult task.
wave of phones will leverage the popular. 8. Yahoo! will come up with some
public Internet for phone com- 4. Smart development managers new innovative Web products
munications and common WAN/ will start creating mixed open that will be able to compete with
LAN. Windows CE and Palm source/commercial environ- Google’s software. If not Yahoo!,
devices will be able to provide ments. For example, you can who else?
voice services. Gone are the days use open source J2EE servers 9. By the end of the year the broad-
of buying a phone dedicated to a in Dev and QA and their com- band Internet will give DSL
single network provider. mercial counterparts in Prod and cable Internet a run for its
5. Self-publishing: Garth and Contingency environments. money. The wireless companies
Brooks and Wal-Mart, LuLu, The same is applicable to DBMS, just need to cut the prices of
MusikMafia. These names all messaging, et al. Some open their broadband service, and the
represent a rise in successful source vendors are already mov- masses will start leaving their
self-publishing. Books, maga- ing in this direction by creating “traditional” ISPs.
zines, and music are all media products that are 100% compat- 10. Java use will steadily increase
that are being self-published ible with particular commercial despite the fact that various
over the Internet. Soon, this tools. replacements are being offered.
will be expanding to software 5. A new software architecture for Java is more than an excel-
as Software as a Service (SaaS) small and mid-size businesses lent object-oriented language
becomes more popular. should arise. IMHO a good enriched by tons of productivity
6. Metadata: Metadata is finally candidate is what I call “Client/ libraries (networking, multi-

40 January 2006 •

threading, security, etc.). It’s a ERIK C. THAUVIN but we will continue to be our own
mature and proven platform for RoR, Web2.0, Open Source Java, worst enemy by subverting good sys-
development of all kinds of applica- IE 7, Google, Yahoo!, spam, tems with bad practices.
tions for all kinds of hardware. Java VoIP, and WiFi 4. Brute force attacks will become more
in programming plays the same 1. Ruby (on Rails) and such will still be prolific and password security will
role as English in the real world: no touted as taking over take center stage once the code is
one says that the Italian language Java, but in reality will be as insignifi- deemed “secure enough.”
will replace English any time soon; cant as they are today. 5. We will likely see the first public case
on the other hand, songs in Italian 2. Web 2.0 will solidify its status as a of terrorists using hacking to bring
sound great. powerful buzzword. A lot down a public utility (whether it is
of fluff, very little stuff. the Internet or the power grid).
Peter Zadrozny, StrongMail’s CTO, 3. Sun will once again dangle the open
naturally has some e-mail predictions: source carrot as Mustang gets closer “I went out on a limb with that
to its release date. last one,” Hynds added, “as it hasn’t
PETER ZADROZNY 4. The IE 7 rate of adoption will be phe- happened yet (successfully) though
Spam/Phishing, AJAX, nomenal, especially I thought it was a good bet back in
PHP, JEE, and SOA compared to Firefox. 2002. Security is a war, don’t fight fair.
5. Sixty percent of Google’s services will You can be assured that the script
1. E-mail will be re-engineered to stop still be in “beta.” kiddies, organized criminals, and ter-
spam and phishing, so it will help 6. Yahoo! will be the first Internet portal rorists won’t.”
legitimate businesses better utilize to come up with a compelling set of
the channel for secure mobile-based services. The last word goes to Quest Software’s
communications such as state- 7. No spam salvation. Many will try, all Tyler Jewell, who has a thought-provok-
ments, purchase orders, customer will fail. ing speculation about Google…
service, etc. 8. VoIP and Wi-Fi will become even
2. As part of the e-mail re-engineer- more synonymous. TYLER JEWELL
ing effort, every sender will have Web 2.0, “GoogleNet”
to implement the authentication Patrick Hynds, coeditor-in-chief of
standards. Unfortunately, there will Information Storage & Security Journal
still be various authentication stan- and CTO of Critical Sites, noted that “If you are going to be covering the
dards. while he doesn’t often venture to predict Web 2.0 phenomenon, will you be
3. AJAX will be adopted like wildfire. things, he does have enough experience highlighting the interesting moves that
4. As PHP becomes more widely “to hazard some guesses as to what this Google is making with buying up dark
adopted as a highly productive, year will bring relative to the field of fiber, massive Internet bandwidths, and
quick and dirty language, more and security.” building prototype data centers that
more people will realize can be located at various points around
that for serious enterprise- PATRICK HYNDS the world? When you look at it all, it’s
grade, industrial-strength Rootkits, .NET 2.0, possible that Google is building a new
applications, they will have to Terror Hacking Internet, a new ISP offering, new services
use Java and JEE. never before conceived of. It’s an interest-
5. Service-oriented architecture will 1. Security will continue to be a hot ing concept.”
continue its very slow and quiet topic and will rise in the priority list
advance in the enterprise. A few of executives (finally) due to the pub- So, let’s have your own contri-
years from now everything will be lic failures of some big names (still butions: e-mail them please to
SOA and we won’tt remember how TBD).
it happened. 2. Rootkits are already all the rage with
the bad guys. 2006 will see the arrival Acknowledgments
Erik C. Thauvin, as befits the of tools to combat them at the con- Parts of this article were informed
author of Erik’s Linkblog and owner sumer level as spyware and anti-virus by discussions with SYS-CON editors,
of, ranged far and wide packages continue to awaken to this writers, and columnists, including
in his predictions. They started with threat. Sean Rhody, Israel Hilerio, Bill Ray,
combative opinions on RoR and 3. .NET 2.0 will help developers write Mark Hinkle, Rob Gonda, and Dion
Web 2.0. more secure code than ever before, Hinchliffe.

to our worldwide network of software
development activists, evangelists, and executives,
2006 promises to be a vintage year for software development” • January 2006
Tips & Tricks

DataWindow.NET How To:

DataWindow Formatting
A simple but powerful way of formatting data in the presentation layer

In this article, we’re has a DataSet defined (ProductData) .BorderStyle =
going to look at how and a constant (PRODUCT_TABLE_ DefaultGridBorderStyle
DataWindow.NET technol- NAME). This particular VB.NET End With
ogy is a simpler but more example, unlike the last two we
powerful way of formatting data in looked at, is a typical ADO.NET The DataWindow implementa-
the presentation layer. sample that uses a DataAdapter and tion of ResetDemo is much simpler
We’ll be taking a sample appli- a DataSet to retrieve and store the because we only need to reset the
cation provided by Microsoft for data and then fill the DataGrid. The properties on the DataWindow
.NET and implementing it using PRODUCT_TABLE_NAME constant control. The properties of the
DataWindow.NET technology. In is used to name the result set of DataWindow object get reset during
this case, we’re using the Visual interest in the DataSet because a the BindDataWindow method when
Basic .NET Code Sample: DataGrid .NET DataSet can actually hold mul- we reassign the DataWindow object
Formatting sample application tiple result sets. to the control.
available at http://www.micro- Each of the command but- tons calls two form methods DataWindow ResetDemo
aspx?FamilyID=28fd458f-5571-42b4- (ResetDemo and BindDataGrid or dw_products.BorderStyle =
a2fe-09b69ddf0863&displaylang=en. BindDataWindow) and then a third DataWindowBorderStyle.None
The original sample was writ- form method for the non-default dw_products.TitleBar = False
ten to connect to the Microsoft styles that sets up that particular dw_products.Text = “”
Northwind sample database. So style (see Table 2).
you’ll need MSDE or SQL Server In the DataGrid implementation, Both the BindDataGrid and
with that sample database installed the ResetDemo method clears the BindDataWindow methods try to
if you want to try it out for yourself. DataSet and then resets each of the connect to the SQL Server version
Also, the sample code for this article various formatting properties that of the Northwind database and then
is intended as an addition to the get set during the demo. try to connect to the MSDE version
original sample so you can compare if the SQL Server version can’t be
them side-by-side. After adding the DataGrid ResetDemo found. The DataGrid implementa-
sample code files from this article If Not IsNothing(ProductData. tion then uses an SqlDataAdapter
to the original sample, you can Tables(PRODUCT_TABLE_NAME)) Then class to retrieve the data from the
switch between the DataGrid and ProductData.Tables(PRODUCT_TABLE_ database and routes it to the DataSet.
BY BRUCE DataWindow implementations by NAME).Clear() Then it assigns that DataSet as the
ARMSTRONG changing the startup form for the End If DataSource for the DataGrid control.
project (see Figure 1).
With grdProducts DataGrid BindDataGrid
Main Form .BackgroundColor = SystemColors. Dim ProductAdapter As New
The main form of the appli- InactiveCaptionText SqlDataAdapter( _
cation consists of a DataGrid or .CaptionText = “” “SELECT ProductID, ProductName,
DataWindow and four command .CaptionBackColor = SystemColors. UnitPrice, UnitsInStock FROM prod-
buttons that apply “Default,” ActiveCaption ucts”, _
“Table Style,” “Column Style,” and .TableStyles.Clear() northwindConnection)
“Grid Properties” formatting to the .ResetAlternatingBackColor() ProductAdapter.Fill(ProductData,
DataGrid or DataWindow control. .ResetBackColor() PRODUCT_TABLE_NAME)
Table 1 shows the results of the .ResetForeColor() grdProducts.DataSource = ProductData.
different formatting applied to .ResetGridLineColor() Tables(PRODUCT_TABLE_NAME)
the DataGrid and DataWindow .ResetHeaderBackColor()
respectively. .ResetHeaderFont() The DataWindow implementation
The primary difference between .ResetHeaderForeColor() of the BindDataWindow method does
the DataGrid and DataWindow .ResetSelectionBackColor() pretty much the same thing using
implementations with regard to .ResetSelectionForeColor() DataWindow related classes. First
form variables is that the DataGrid .ResetText() the OleDB connection is bound to a

42 January 2006 •

DataWindow.AdoTransaction object. .BackColor = Color.GhostWhite AUTHOR BIO:
We then reset the DataWindow object .ForeColor = Color.MidnightBlue We’ll implement others by doing Bruce Armstrong is a senior
assigned to the DataWindow control, .GridLineColor = Color.RoyalBlue SetProperty calls on the underlying programmer with Integrated
assign the AdoTransaction object to the .HeaderBackColor = Color. DataWindow object. I’ve subclassed the Data Services (www.get-
DataWindow control, and then retrieve MidnightBlue DataWindow control and added meth- integrated.com0). A member
the DataWindow. .HeaderFont = New Font(“Tahoma”, ods for setting a number of the font and of TeamSybase, he has been
8.0!, FontStyle.Bold) color properties. using PowerBuilder since
DataWindow BindDataWindow .HeaderForeColor = Color.Lavender version 1.0.B. He was a con-
Dim SQLCA As New Sybase.DataWindow. .SelectionBackColor = Color.Teal dw_products.SetDataWindowColor(Color. tributing author to SYS-CON’s
AdoTransaction(conn, “”) .SelectionForeColor = Color. GhostWhite) PowerBuilder 4.0: Secrets of
SQLCA.BindConnection() PaleGreen dw_products.SetDataWindowBandColor the Masters and editor of SAM’s
.MappingName = PRODUCT_TABLE_NAME (BandType.Detail, Color.Lavender) PowerBuilder 9: Advanced
dw_products.LibraryList = “dwgridfor- .PreferredColumnWidth = 125 dw_products.SetColumnFont(New Client/Server Development.
matting.pbl” .PreferredRowHeight = 15 Font(“Tahoma”, 8.0!))
dw_products.DataWindowObject = “” End With dw_products.SetColumnBackColor(Color. 4
dw_products.DataWindowObject = “d_g_ grdProducts.TableStyles.Add GhostWhite)
products” (grdTableStyle1) dw_products.SetColumnColor(Color.
dw_products.SetTransaction(SQLCA) MidnightBlue)
dw_products.CreateHeaderSortArrows() The FormatGridWithBothTableAnd dw_products.SetHeaderBackColor
dw_products.Retrieve() ColumnStyles method (only an excerpt (Color.MidnightBlue)
is shown below) uses both of those dw_products.SetHeaderFont(New Font
The FormatGridwithoutTableStyles, approaches and also defines a series of (“Tahoma”, 8.0!, FontStyle.Bold))
FormatGridwithTableStyles, and Forma DataGridTextBoxColumn objects to han- dw_products.SetHeaderColor(Color.
tGridwithBothTablesAndColumnStyles dle the formatting of specific columns. Lavender)
methods are all somewhat similar. The The DataGridTextBoxColumn objects are dw_products.SetColumnWidth(100)
FormatGridwithoutTableStyles method then assigned to the DataGridTableStyle dw_products.SetRowHeight(15)
(only an excerpt is shown below) sets the before it’s applied to the DataGrid.
format by manipulating the properties of Note that there are a couple of prop-
the DataGrid itself. FormatGridWithBothTableAnd erties that the DataGrid lets you set that
ColumnStyles the DataWindow doesn’t give us any
FormatGridWithoutTableStyles Dim grdColStyle1 As New control over. Specifically with regard to
With grdProducts DataGridTextBoxColumn() this demo, we can’t set the font or colors
.BackColor = Color.GhostWhite With grdColStyle1 for the caption (the DataWindow control
.BackgroundColor = Color.Lavender .HeaderText = “ID” title area). I imagine that we might be
.BorderStyle = BorderStyle.None .MappingName = “ProductID” able to do it by overriding the painting
.CaptionBackColor = Color.RoyalBlue .Width = 50 of the title bar in the subclassed control,
.CaptionFont = New Font(“Tahoma”, End With but I’m not interested enough in those
10.0!, FontStyle.Bold) . particular attributes to try it. The other
.CaptionForeColor = Color.Bisque . properties of interest in this particular
.CaptionText = “Northwind Products” . example are the fore and back colors for
.Font = New Font(“Tahoma”, 8.0!) grdTableStyle1.GridColumnStyles. the band indicating the selected row(s)
.ParentRowsBackColor = Color. AddRange _ and color of the grid lines.
Lavender (New DataGridColumnStyle() _ To get the same effect as the
.ParentRowsForeColor = Color. {grdColStyle1, grdColStyle2, grdCol- DataGridTextBoxColumn object, we just
MidnightBlue Style3, grdColStyle4}) set the properties for individual columns
End With of the DataWindow object:
Now, the most obvious thing to
The FormatGridwithTableStyles do if you want generic formatting of a
method (only an excerpt is shown DataWindow is to set up that formatting
below) takes the same approach for in the DataWindow object to begin with.
many properties, but it also defines a However, the point of this “how to” is to
DataGridTableStyle object to handle show how we can do it through code, so
some of the other properties and then we’ll do that instead.
assigns that to the DataGrid: Some of the formatting of the
DataWindow we’ll do by setting the
FormatGridWithBothTableAnd properties of the control itself:
Dim grdTableStyle1 As New dw_products.BorderStyle = Sybase.
DataGridTableStyle() DataWindow.DataWindowBorderStyle.None
With grdTableStyle1 dw_products.TitleBar = True
.AlternatingBackColor = dw_products.Text = “Northwind
Color.GhostWhite Products” f1 Figure 1: Setting the start form for the project • January 2006

Tips & Tricks
dw_products.SetProperty(“productid. Dim modify As String moveable. To prevent the control
width”, “50”) modify = dw_products.GetRGB from being moved, we monitor for the
dw_products.SetProperty(“unitprice. (Color.MidnightBlue) + _ WM_SYSCOMMAND message (which
width”, “75”) “~tif ( unitsinstock < 5,” + _ is passed to WndProc) and determine
dw_products.SetProperty(“unitsinst dw_products.GetRGB(Color.Red) if a SC_MOVE is being attempted. If so,
ock. + “,” + _ we return from the overloaded method
width”, “75”) dw_products.GetRGB(Color.Midnight without calling the ancestor – other-
Blue) + “)” wise we call the ancestor so normal
Note that the DataGrid doesn’t dw_products.SetProperty(“units processing can continue.
offer much manipulation of the col- instock.Color”, modify)
umn-level properties. For example, WndProc
the DataGridTextBoxColumn object For a DataWindow object property Protected Overrides Sub WndProc(ByRef
doesn’t provide access to color attri- expression, the default value is followed m As System.Windows.Forms.Message)
butes – so you can’t set the color for by a tab character (“~t”) and then the Const WM_SYSCOMMAND As Long = &H112
individual columns. There are ways to expression used to derive the value. Const SC_MOVE As Int32 = &HF010
overcome this, but they involve a great Now let’s take a look at some of If m.Msg = WM_SYSCOMMAND Then
deal more effort than a SetProperty the code we had to implement to give ʻThe four low order bits of wParam
call. For more information, you can the DataWindow control a bit more are used internally by Windows,
refer to George Shephard’s Windows of a DataGrid look-and-feel. One item ʻso we need to do a bitwise and
Forms FAQ for DataGrid controls at of code was added to the Click event with FFF0 to get the real value. handler for the DataWindow control If ((m.WParam.ToInt32 And &HFFF0)
FAQ/WindowsForms/FAQ_c44c.aspx in the form (see below). It sets the = SC_MOVE) Then Exit Sub
Many of the features listed in the row to selected if the user clicks on End If
FAQ that take some effort to imple- the first column of the row. Note the MyBase.WndProc(m)
ment (setting row height, outthought SelectRow(0,False) call, which deselects End Sub
rows, displaying a data-driven com- all previously selected rows. If we want-
bobox or other edit controls (check- ed to allow multi-selection, we would We also override the OnClick meth-
box)) are simply a matter of setting a check the selected status of the current od. The DataWindow control doesn’t
property or adding an edit style to the row and toggle it rather than clearing natively support a click-on-column
DataWindow object. the selection status of all rows. header sort operation. The overridden
Also note that once you start defin- method uses the PFC click-on-column
ing DataGridTextBoxColumn objects, DW_Products_Click header code modified to work in a
you have to create one for each column Dim clickedobject As Sybase. .NET environment.
you want to display in the DataGrid DataWindow.ObjectAtPointer
regardless of whether you want to clickedobject = CType(sender, OnClick
change its formatting. If you specify DataWindowControl). Protected Overrides Sub OnClick
DataGridTextBoxColumn objects for ObjectUnderMouse() (ByVal e As EventArgs)
some – but not all – of the columns Select Case clickedobject.Band.Type Dim clickedobject As Sybase.
in the DataSet, only the columns Case Sybase.DataWindow.BandType. DataWindow.ObjectAtPointer
that have a DataGridTextBoxColumn Detail Dim objectname, columnname, sort
object defined for them will display. CType(sender, DataWindow As String
(Shepard’s FAQ offers a workaround Control).SelectRow(0, False) clickedobject = MyBase.Object
for this particular behavior). With the If clickedobject.RowNumber > 0 UnderMouse()
DataWindow control, you can alter the Then Select Case clickedobject.Band.Type
formatting for any number of columns If clickedobject.Gob.Name = Case Sybase.DataWindow.BandType.
without affecting the visibility of the “c_1” Then Header
other columns in the result set. CType(sender, objectname = clickedobject.Gob.Name
However, the main advantage of the DataWindowControl) If objectname.Substring(objectname
DataWindow over the DataGrid with .SelectRow(clickedobject. .Length() - 2, 2) = “_t” Or _
regard to formatting is that many of the RowNumber, True) objectname.Substring(objectname.
DataWindow object properties accept End If Length() - 2, 2) = “_a” Then
expressions that can be used to deter- End If columnname = objectname.Sub
mine their value. Those expressions End Select string(0, objectname.Length()
can use functions that determine state - 2)
information for the control, or refer to Subclassed DataWindow Control If columnname = sortcolumnname
data in the control. This lets you specify The remainder of the addi- Then
formatting not just for individual col- tional code is in our subclass of the If sortorder = “ A” Then
umns, but for individual cells. For DataWindow control. The first thing we sortorder = “ D”
example, in the FormatDataWindowTa did is override the WndProc method. Else
bleStyle method if there are no units in One problem with the DataWindow sortorder = “ A”
stock, we set the color of the text in the control is that if you make the title End If
unitsinstock column to red as follows: bar visible, it also makes the control Else

44 January 2006 •

sortcolumnname = columnname
sortorder = “ A”
End If
sort = sortcolumnname +
End If
End Select
End Sub

One of the main reasons for over-

riding the DataWindow control – other
than to get it not to move when the
title bar is shown – is because the
DataWindow object color properties
take RGB values. The system color val-
ues in the .NET framework are ARGB
values (they contain an alpha compo-
nent). The GetRGB method that I added
converts the ARGB value to an RGB
value that the DataWindow can use.

Public Function GetRGB(ByVal theColor
As Color) As String
Dim theRGB As Long
theRGB = RGB(theColor.R(), theColor.
G(), theColor.B())
Return theRGB.ToString()
End Function

The color setting methods I’ve

added to the subclassed control accept
.NET system colors and call that meth-
od internally to convert the value and
then set the appropriate DataWindow
object property. One example of this is
the SetColumnBackColor method; the
other color setting methods are similar.

Public Sub SetColumnBackColor
(ByVal theColor As Color) t1 Table 1: DataGrid and DataWIndow formatting examples
Dim columns As ArrayList =
GetVisibleColumns() DataWindow object and I’ve added a For Each col In columns
Dim col As String method to the overridden control to MyBase.SetProperty(obj + “.Back
For Each col In columns make it simpler. Ground.Mode”, “0”)
MyBase.SetProperty(obj + rc = MyBase.SetProperty(col +
“.BackGround.Mode”, “0”) SetRowAlternatingColors “.Background.Color”, modify)
MyBase.SetProperty(col + “.Back Public Sub SetRowAlternating Next
ground.Color”, GetRGB(theColor)) Colors(ByVal OddColor As Color, End Sub
Next ByVal EvenColor As Color)
End Sub Dim columns As ArrayList = Similar to the issues with the .NET
GetVisibleColumns() system colors, the .NET Framework
One of the color settings that the Dim col, modify As String Font is a class whereas the DataWindow
DataWindow control doesn’t provide Dim rc As Int32 has a series of independent font prop-
native support for is to have alternating modify = GetRGB(OddColor) + _ erties. The Font setting methods I’ve
rows appear with different background ~tif ( MOD( getrow(),2 )=0 ,” + added to the subclassed DataWindow
colors. That’s done easily enough by GetRGB(EvenColor) + “,” + control accept the .NET Framework
adding a property expression to the GetRGB(OddColor) + “)” Font class and then access the indi- • January 2006

Tips & Tricks
Another native feature of the
DataGrid control is the display of a
sort arrow indicator in the column
headers when the column header
click is used to sort that column. I’ve
incorporated that using a .NET imple-
mentation of the grid sort indicator
sample from TopWizProgramming.
The CreateHeaderSortArrows method
t2 Table 2: Form methods called by command dynamically creates a set of computed
columns for every column header (at
vidual properties. One example is the an array containing all of the columns the same position and same size as the
SetColumnFont method; the other font in the DataWindow object. column headers) that automatically
setting methods are similar. displays an up or down arrow based on
GetColumns the DataWindow object sort expression
SetColumnFont Public Function GetColumns() (See Listing 1).
Public Sub SetColumnFont(ByVal As ArrayList Another modification was made
theFont As Font) Dim i, j As Int16 directly to the DataWindow object.
Dim columns As ArrayList = j = MyBase.ColumnCount() The DataWindow control has a
GetVisibleColumns() Dim columns As New ArrayList SetRowFocusIndicator that takes a
Dim col As String Dim columnname As String bitmap that can be used to indicate
For Each col In columns For i = 1 To j what the current row is. In most grid
MyBase.SetProperty(col + columnname = MyBase.GetProperty(“#” DataWindow implementations turning
“.Font.Face”, theFont.Name) + i.ToString() + “.Name”) on row selection for the row usually
MyBase.SetProperty(col + columns.Add(columnname) indicates this. However, I was trying to
“.Font.Height”, “-” + Next mimic the DataGrid style as much as
theFont.Size.ToString()) Return columns possible. The SetRowFocusIndicator
Next End Function wasn’t giving me quite the results I
End Sub wanted. So instead, I added a com-
A particular problem is deter- puted column to the DataWindow with
There are some helper functions mining which of the columns in an expression of:
defined for the subclassed control as the DataWindow actually have a
well. One is the GetHeaderObjects control present on the surface of the if ( currentRow() = getRow(), ʻ4ʼ,
method. It looks through all of the DataWindow object. The DataWindow ʻʼ )
controls on the DataWindow object will throw an exception if you attempt
and determines which are static text to access certain properties of a col- and then set the font for that column
controls in the header band. umn and it doesn’t have those prop- to Marlett.
erties because they’re visible control
GetHeaderObjects properties. I found that attempting Conclusion
Public Function GetHeaderObjects() As to access the Band property works, As we’ve seen, the DataWindow
ArrayList and columns without a visible con- provides much of the same function-
Dim objects, obj As String trol report back “?” for the band. The ality as the DataGrid control. Most
Dim objarray As String() GetVisibleColumns method then of the areas where the DataGrid pro-
Dim headerobjects As New ArrayList returns an array containing only those vides functionality not native to the
objects = MyBase.GetProperty columns that have a visible control. DataWindow – sort on column
(“DataWindow.Objects”) header click and sort indicators –
objarray = objects.Split(vbTab. GetVisibleColumns are easily added by subclassing the
ToCharArray()) Public Function GetVisibleColumns() control and adding a few lines of
For Each obj In objarray As ArrayList code. On the other hand, the Data-
If MyBase.GetProperty(obj + Dim columns As ArrayList = Get Window offers functionality not easily
“.Type”) = “text” Then Columns() implemented in the DataGrid primar-
If MyBase.GetProperty(obj + Dim visiblecolumns As New ArrayList ily because:
“.Band”) = “header” Then Dim band, col As String 1. The separate DataWindow object
headerobjects.Add(obj) For Each col In columns lets the developer create the visual
End If band = MyBase.GetProperty(col + presentation of the data via the
End If “.Band”) DataWindow Designer painter rath-
Next If band <> “?” Then er than having to code it in script.
Return headerobjects visiblecolumns.Add(col) 2. Most of the DataWindow object
End Function End If properties accept expressions that
Next self-evaluate so properties can auto-
A somewhat similar approach is Return visiblecolumns matically change based on changes
used by the GetColumns method to get End Function to the state or value of data.

46 January 2006 •

Listing 1: CreateHeaderSortArrows exprsn = “””if(pos(lower(describe(ʻdatawindow.table.sortʼ)),
Public Sub CreateHeaderSortArrows() ʻ”
Dim fontsize As Int16 exprsn += col + “ aʼ) > 0, ʻ5ʼ, “
Dim syntax, xpos, width, height, exprsn += “if(pos(lower(describe(ʻdatawindow.table.sortʼ)), ʻ”
color, exprsn, align, col, exprsn += col + “ dʼ) > 0, ʻ6ʼ, “
fontheight As String exprsn += “if(pos(lower(describe(ʻdatawindow.table.sortʼ)), ʻ”
Dim myGOB As Sybase.DataWindow.
exprsn += “lookupdisplay(“ + col + “) aʼ) > 0, ʻ5ʼ, “
exprsn += “if(pos(lower(describe(ʻdatawindow.table.sortʼ)), ʻ”
exprsn += “lookupdisplay(“ + col + “) dʼ) > 0, ʻ6ʼ, ʻʼ))))”” “
If MyBase.GetProperty(“DataWindow.
Processing”) <> “1” Then Return
Dim columns As ArrayList = syntax = “create compute( band=header alignment=””” + align +
GetVisibleColumns() “”” expression=” + exprsn
For Each col In columns syntax += “border=””0”” color=””” + color + “”” x=””” + xpos +
xpos = MyBase.GetProperty(col + “”” y=””0”” “
“.X”) syntax += “height=””” + height + “”” width=””” + width + “””
width = MyBase.GetProperty(col + format=””[general]”” “
“.width”) syntax += “name=” + col + “_a font.face=””Marlett”” font.
height = MyBase.GetProperty(col + height=”” + fontheight + “” “
“.height”) syntax += “font.weight=””400””””0”” font.
fontheight = MyBase.GetProperty(col pitch=””2”” font.”
+ “.font.height”)
syntax += “charset=””2”” background.mode=””1”” background.
fontsize = CType(fontsize.Parse(fontheight) * 1.2, Int16)
color=””553648127”” )”
fontheight = fontsize.ToString()
color = “0”
If MyBase.GetProperty(col + “.alignment”) = “1” Then
align = “0”
Else Next
align = “1”
End If End Sub

Advertiser Index

AJAX Seminar 201-802-3022 25

.NET Developer’s Journal 888-303-5282 35
CFDynamics 866-233-9626 17
ESRI 888-288-1277 6
Forum Systems 866-333-0210 15
GraphOn 800-GRAPHON 21 800-446-7627 11
IT Solutions Guide 888-303-5282 47 Conference & Expo 201-802-3023 27
KaPow Technologies 800-805-0823 Cover III
MapInfo 800-327-8627 Cover II
Parasoft 888-305-0041 Cover IV
RadView Software 888-RADVIEW 3
Synaptris 866-99IVIEW 13
SYS-CON Events 201-802-3066 49
Verio 866-237-4121 9
Visual Paradigm 408-426-8212 5
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
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
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.
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
of their advertisements printed in .Net Developer’s Journal. Advertisements are to be printed at the discretion of the Publisher. This discretion
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. • January 2006

Book Review

.NET 2.0 Generics

Everything you need to know about this powerful new feature

ET 2.0 Generics is my cute generics, and shows how the
favorite book of 2005. use of generics affects code speed
Well, other than Harry and size.
Potter anyway. This book There are three chapters in
is not for new programmers. To this book from which I expect to
understand this book, I would get heavy use as a reference on
recommend that you have about a a day-to-day basis. The first is a
year of programming experience, chapter on BCL generics, or the
and at least six months with C++, generic classes that come with the
C#, or Java. This book is well writ- .NET Framework. Most of these are
ten and is best used as an introduc- container classes, and this chapter
tion to generics, so it is of most covers how they work, including
use to an advanced beginner. The how to add, access, and remove
reader should be familiar the syn- items to each type of generic collec-
tax of a C-derived language such as tion. The second chapter I expect
C++, Java, or C# 1.x, and be familiar to reference almost daily covers the
Title: .NET 2.0 Generics
with object oriented-programming “Power Collections” sponsored by
Author: Tod Golding
issues such as inheritance, over- Wintellect at
Publisher: Wrox
loading, and overriding. No knowl- There are several open source proj-
edge of generics is needed to make ISBN #: 0-7645-5988-5 ects creating generic collections for
use of this book. Price: US $39.99 .NET (as well as a lot of private com-
On the other hand, unless you panies doing the same). Of these,
are a wizard with .NET generics, pointed out that the complexity Power Collections is one of the
you are likely to learn a lot from of templates in C++ has to some larger and better known, and they
this book. For example, C++ pro- extent given generics a bad name, also work closely with Microsoft
grammers: What is the difference and how generics, although not (rumors are that the best and most
between templates and generics? quite as powerful as templates, popular of the Power Collection will
The easy answer is that templates keep some of this complexity at be included in future versions of the
work at compile time, and gener- bay. It then covers simple generic .NET Framework). There is a long
BY DENNIS HAYES ics work at run time, but there is classes and follows up with chap- chapter at the end of the book that
a short chapter that details the ters on generic methods and covers the Power Collections in the
Dennis Hayes is an independent real differences. Although most of generic delegates. It also covers same way the earlier chapter covers
software consultant in Atlanta, GA, the book concentrates on C# and constraints, which allow only types the current .NET generics.
and has been involved with the VB.NET, there are two chapters that with certain attributes or capabili- The third chapter that will get
Mono project for over three years. detail the nuances of using gener- ties to be added to the collection. continued use from me is a set of
ics with C++ and J#. The C++ chap- An example is a generic container rules and principles to apply when ter also discuses how to combine that is meant to hold data table creating your own generic classes.
templates and generics together to objects, and is given constraints A key premise of this book is that
get the best of both worlds, and has that require any object added to it generics are so powerful that you
a short discussion on the STL.NET to have sort and update methods. should not only use the ones pro-
library that actually makes use of The book also contains an vided by Microsoft and others, but
the combination. advanced chapter on how generics you should also create new ones as
The book starts off discuss- can be created or analyzed using a part of all of your applications,
ing the way collections in .NET reflection, how they are serialized just as you do classes. The rules
1.1 work by having members be and deserialized, and how they work in the Generics guidelines chap-
objects, and how the need to cast with remoting and Web services. ter distill a lot of experience with
types to and from objects clutters For those who want to know generics and can help programmers
and complicates programs. It then what is happening “under the avoid many of the most common
shows how generics can clean up hood,” this book has a chapter that mistakes.
the clutter and make programs gives details on how compilers and This is a must-have book for
clearer and more flexible. It is also the run time implement and exe- anyone using .NET 2.0.

“This is a must-have book for anyone using .NET 2.0”

48 January 2006 •


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

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


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

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

� � ��������������������
������������������������events������������ � � �����������������������

� ���������������23 �����������

Mono Releases Version 1.1.10

and New Roadmap
Portable.NET gets two $4,500 grants
Mono Version 1.1.10 to the store. Mono now has a tool to new feature has been added to track
Version 1.1.10 is another release import certificates from Mozilla, thus page access, and it has been used to
packed with new code. The release making this job much easier. minimize page faults. The memory
notes can be found at www.go-mono. The JavaScript compiler has sup- used by internal data structures has
com/archive/1.1.10/, and can be port for multiple file compilation as also been reduced. There is a new
downloaded from www.mono-project. well as the import statement, and profiler mono-profiler-aot, which cre-
com/Downloads. Mod_mono, the can late bind to objects derived from ates files that can be fed back into the
ASP.NET module for the Apache Web System.Object. It now passes 6,981 out ahead-of-time compiler to improve
Server, now has an autoconfiguration of the 7,229 Mozilla test cases that it the physical layout of executables.
tool that eliminates the old require- can compile. Exception processing when the
ment that administrators manually After the addition of Friend exception object is not used has been
import all of the directories containing Assemblies and External Alias quali- optimized, mul_imm optimizations
ASP.NET code. This tool allows an ASP. fiers, the only feature left for C# 2.0 is have been ported from the old JIT
NET application to work with no con- boxing related to nullable types, which engine to mini (the new JIT engine),
figuration changes to Apache; similar relates to changes made just before and DateTime parsing has been
to how PHP works under Apache, optimized.
all files with ASP.NET extensions are LDAP received a number of bug
automatically handled by Mono. fixes and performance enhancements.
Mod_mono also now works correctly The Mono.Unix namespace has been
with virtual hosts, so individual servers reorganized, and now supports arbi-
can be restarted using the mod_mono trary file names that were not support-
control panel. ed by the old character encoding. The
Mono will make its next major old versions of methods that changed
release, version 1.2, when System. are still available, but are marked as
Windows.Forms is ready. The cur- obsolete. The plan is to stabilize the
rent plan is to have System.Windows. Mono.Unix API before the 1.2 release.
BY DENNIS HAYES Forms complete by the end of Visual Studio 2005 shipped. Novell will Mono is now relocatable on Linux and
November 2005 (I am writing this in be focusing on Mono 1.2, and will not Solaris 10 systems; move any Mono
Dennis Hayes is an independent early November), and spend three be working on C# 3.0 features until package or RPM to any directory, and
software consultant in Atlanta, GA, months on bug fixes before releasing after Mono 1.2 ships. This of course it will continue to work. Mono.Cairo
and has been involved with the in late February. The 1.1.10 release does not prevent anyone else from has received over a dozen significant
Mono project for over three years. includes bug fixes, performance starting on those features, and they changes.
enhancements, and drag-and-drop should appear quickly after 1.2 ships, Miguel de Icaza has blogged and menu improvements while run- as all C# 3.0 features are expected to about current the status of Mono
ning under X11. It also includes a .NET take less effort than generics alone in and Novell’s (unofficial) priorities for
2.0 DataGridView, courtesy of the C# 2.0. Mono. The blog is at http://tirania.
Google Summer of Code. Additions to the class libraries still org/blog/archive/2005/Nov-17.html.
For performance reasons, System. continue to add .NET 2.0 features, and Miguel also plans to write another
Drawing no longer requires permis- most important, System.Configuration blog on the priorities of contributors
sions to call unmanaged code. Code is being worked on to support ASP. other than Novell.
Access Security (CAS) has been added NET 2.0. System.XML had some meth-
to system.dll, and is being added to od changes to match the final version Portable.NET
System.Web.dll. ProtectedData is now from Microsoft. The System.Delegate Portable.NET has received two
supported using DAPI on Windows, namespace received code for contra- grants of $4,500 US each. The first is
and managed code on Linux; also, variant and covariant delegates. for the completion of LibJIT, a generic
protected memory nor works under As Mono moves toward the 1.2 compiler engine that can take inter-
Windows. Assemblies can be signed release, performance gets more mediate code in three-address form
with RSA key pairs ranging from 384 to attention, and 1.1.10 reflects that. Jon (no more than three address per line),
16,384 bits. Trowbridge has written a heap pro- and output native code (see Monkey
By default, the Mono certificate filer (heap-buddy), which has put a Business in .NETDJ Vol. 2, iss. 6). The
store is empty, and in the past users lot of the framework classes on diets, second grant of $4,500 is for a C# front
have had to add certificates they trust especially StreamReader.Readline. A end to LibJIT.

50 January 2006 •