Mark Wilson I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First posted :
03/24/2008
Times viewed :
284
Data with a TreeView
Transforming XML to HTML with XSLT stylesheets is a good option
if the HTML pages are relatively static. If the generated web pages leverage
DHTML effects to a large degree or if we need to process user input then
server-side controls offer a much better programming model. With server side
controls we can process user input through event notifications, you will see
what I mean shortly. ASP.NET provides a great framework to handle the
notifications, which makes writing interactive very pages very simple. Building
interactive pages with XSLT would by-pass that framework and we have to write
server-side and client-side code to process user events by hand.
The next server-side control we examine closer is a TreeView. I
think you are familiar with tree view controls because you use them on a
regular basis. The MSDN web site, for example, presents the contents of the
documentation library in a web based tree view, shown in figure 17.8. Initially
this Tree View only displays the top level of library categories. You click on
the area of articles you are looking for and the tree expands to show more
choices for that area. The new choices can also lead to more choices or they
can link to articles in the library.
Figure 17.8: The MSDN web site displays the available library categories in the
tree view on the left hand side of the page.
Since a tree view naturally maps to hierarchical structures, it
is very well suited to display data from XML documents. It is also well suited
for web based applications because we do not have to populate the entire tree
right away. We can populate only the displayed tree nodes to reduce the amount
of data going from the web server the browser, which reduces transfer time and
speeds up the rendering of the page in the browser.
There are several different Tree View controls available for
ASP.NET. The Microsoft TreeView Web Control we are working with in this section
is not distributed with the .NET Framework, but it is available as a free
download on the MSDN website at http://msdn.microsoft.com/library/default.asp?url=/workshop/webcontrols/webcontrols_entry.asp.
This control only displays properly in Internet Explorer, but it works nicely
with XML data because it allows binding XML documents to build the tree.