asp tutorials, asp.net tutorials, sample code, and Microsoft news from 15Seconds
Data Access  |   Troubleshooting  |   Security  |   Performance  |   ADSI  |   Upload  |   Email  |   Control Building  |   Component Building  |   Forms  |   XML  |   Web Services  |   ASP.NET  |   .NET Features  |   .NET 2.0  |   App Development  |   App Architecture  |   IIS  |   Wireless
 
Pioneering Active Server
 Power Search





Active News
15 Seconds Weekly Newsletter
• Complete Coverage
• Site Updates
• Upcoming Features

More Free Newsletters
Reference
News
Articles
Archive
Writers
Code Samples
Components
Tools
FAQ
Feedback
Books
Links
DL Archives
Community
Messageboard
List Servers
Mailing List
WebHosts
Consultants
Tech Jobs
15 Seconds
Home
Site Map
Press
Legal
Privacy Policy
internet.commerce














internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

HardwareCentral
Compare products, prices, and stores at Hardware Central!

How to Implement Different Types of Outlines in ASP
By Dima Khanine
Rating: 1.5 out of 5
Rate this article


  • email this article to a colleague
  • suggest an article

    Introduction

    In this article Dima Khanine illustrates how to outline a web site and how to implement that outline in server side code.

    Why Do We Need Outlines on the Web?

    More and more Web sites are coming on line every day and to attract surfers to your site is becoming more difficult. To retain our users’ attention we need to make their interaction with the Web site as easy as possible, so they can find what they’re looking for fast. For example, part of Yahoo’s success is the excellent, structured organization of the site. Outlines can help us to get organized.

    Why Do We Need Them on the Server Side?

    While client scripting is becoming more reliable, keeping your HTML output as simple as possible is still a good practice, especially if you are not sure which browser your customer uses. Server-side implementation will make your outlines browser-independent.

    Another consideration is the amount of data the client has to download. Let’s say there is an employee table grouped by department:

    Department

    Employee

    1123

    Dave Smith

    1123

    John Dow

    1123

    Steve Richards

    1157

    Dan Stevenson

    1161

    Roger Hawker

    This table can be quite large and its download time may significantly decrease the performance of your Web application. With an outline the user will only get the data he (she) really needs:

    1. 1123
    2. 1157
    3. Dan Stevenson
    4. 1161
    5. ...

    How to Implement This in ASP

    We all recognize there are many ways to accomplish the same task. I’m not pretending here to show you the best algorithm, but I’ll try to give you an idea of how outlines may be easily written on ASP. First let me remind you that an ASP page is stateless until you use Session or the like mechanism to maintain your state between calls, so we need to get our outline state each time from the query string.

    Note in the following examples I use a VB 2-dimensional array to store outline data. You may want to use recordset or another source of data in your applications. However this will only require some minor changes, like adding a call to the MoveNext method of your recordset object just before the outer loop operator.
    Let’s start from the very basic simple outline where only one branch could be open at a time.

    The code that produces this output is listed below.

    
    <%@ Language=VBScript %>
    <%Option Explicit%>
    <%
    	‘ Array initialization
    	Dim items(10,2), maxItems
    	maxItems = 9
    	items(0,0) = "Item 1"
    	items(1,0) = "Item 1"
    	items(2,0) = "Item 1"
    	items(3,0) = "Item 2"
    	items(4,0) = "Item 2"
    	items(5,0) = "Item 2"
    	items(6,0) = "Item 3"
    	items(7,0) = "Item 3"
    	items(8,0) = "Item 3"
    	items(9,0) = "Item 3"
    
    	items(0,1) = "SubItem 1.1"
    	items(1,1) = "SubItem 1.2"
    	items(2,1) = "SubItem 1.3"
    	items(3,1) = "SubItem 2.1"
    	items(4,1) = "SubItem 2.2"
    	items(5,1) = "SubItem 2.3"
    	items(6,1) = "SubItem 3.1"
    	items(7,1) = "SubItem 3.2"
    	items(8,1) = "SubItem 3.3"
    	items(9,1) = "SubItem 3.4"
    %>
    
    <%
    	‘ Outline starts here
    	Dim index,currentItem, openItem
    	openItem = Request.QueryString("open")
    %>
    <HTML>
    <HEAD>
    	<TITLE>ASP Outline sample</TITLE>
    </HEAD>
    <BODY>
    	<h2>Regular outline</h2>
    	<UL>
    	
    	<%
    		index = 0
    		Do while index <= maxItems
    			if items(index,0) <> currentItem then 
    
    				‘ only closed branches may have links to open
    				If items(index,0) <> openItem then _
    					Response.Write("<a href='outline.asp?open=" & _
    					Server.URLEncode( items(index,0) ) & "'>"  )
    					Response.Write( "<LI>" & items(index,0) & "</a>" )
    				End If
    				
    				currentItem = items(index,0)
    				If items(index,0) = openItem then 
    					‘ Expand an open branch
    					Response.Write("<UL>")
    					Do While index <= maxItems AND items(index,0) = openItem
    
    						‘ >> Insert your <a href=””> tag here
    						Response.Write( "<LI>" & items(index,1) )
    						‘ >> Corresponding </a> goes here
    
    						index = index + 1
    					Loop
    					Response.Write("</UL>")
    					
    				End If
    			index = index + 1
    		Loop
    	%>
    	
    	</UL>
    
    </BODY>
    </HTML>
    
    
    The main idea of this sample is that we cycle through the whole data set and output only if the first column is changed or to expand the open branch.

    I hope you will find this code useful. In the next article I’ll show how to produce an enhanced outline where multiple branches may be opened at once.

  • Rate This Article
    Not HelpfulMost Helpful
    1 2 3 4 5
    Other Articles
    Aug 7, 2002 - Using MySQL in the Win32 Environment
    Developers who don't want to spend a lot of money on SQL Server and who want a database that's more robust than Access may find MySQL to be a pleasant alternative. This introductory article covers the bare essentials for getting MySQL installed and running in the Win32 environment.
    [Read This Article]  [Top]
    Jul 17, 2002 - Software Development: Steps To Better Ensure Success
    There is never a guarantee of project success when endeavoring to build a sophisticated application. However, there are established steps to follow that will ensure a clear, concise scope, support for the team involved, and a solid opportunity for successful deployment.
    [Read This Article]  [Top]
    Jul 15, 2002 - Securing SQL Server for Web Applications
    If your SQL Server is exposed to the Internet, then hackers are probing it. This article shows how to secure a SQL Server database that's being used with a Web application
    [Read This Article]  [Top]
    Jul 1, 2002 - Protecting Your Web Application Against Dangerous Requests
    Enrico Di Cesare provides a solution for hiding and securing querystring values that pass through a url.
    [Read This Article]  [Top]
    Apr 2, 2002 - Object-Oriented Programming for VBScripters
    Feel intimidated by .NET? This article by Rob Chartier is designed to ease any level VBScripter (ASP) into .NET by clarifying some OOP concepts.
    [Read This Article]  [Top]
    Mar 27, 2002 - A Best Practice for Using ADO Objects
    A few members of the 15 Seconds discussion list talk about the proper way to use methods in order to prevent ADO object errors.
    [Read This Article]  [Top]
    Jan 2, 2002 - The ASP.NET Page Life Cycle
    Solomon Shaffer explores the life cycle of an ASP.NET page from initialization to unloading. He also explains the various methods to override ASP.NET server-side events.
    [Read This Article]  [Top]
    Dec 19, 2001 - Application Architecture: An N-Tier Approach - Part 2
    Rob Chartier creates a simple portable and reusable address book in .NET to demonstrate the power of N-tier application architecture. Complete source code included!
    [Read This Article]  [Top]
    Oct 23, 2001 - Application Architecture: An N-Tier Approach - Part 1
    Learn about N-tier application architecture and realize that developing with multiple layers produces a flexible and reusable application for distribution to any number of client interfaces.
    [Read This Article]  [Top]
    Oct 23, 2001 - Application Architecture: An N-Tier Approach - Part 1
    Learn about N-tier application architecture and realize that developing with multiple layers produces a flexible and reusable application for distribution to any number of client interfaces.
    [Read This Article]  [Top]
    Mailing List
    Want to receive email when the next article is published? Just Click Here to sign up.

    Support the Active Server Industry

    internet.comearthweb.comDevx.commediabistro.comGraphics.com

    Search:

    Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

    Jupitermedia Corporate Info

    Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
    Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers