paging folders

E

Eugene Anthony

The code bellow will display a list of folders in a directory. Now lets
say I have 20 folders, I want to display the first 10 folders, then
display another 10 folders just like the paging concept how is it done?


<table cellpadding="3" cellspacing="0" border="0" width="420">
<tr>
<td width="120"> </td>
<td width="300">

<%
Set objFSO =
Server.CreateObject("Scripting.FileSystemObject")

If objFSO.FolderExists(myFolderPath) Then
'The main picture folder exists
Set objPicturesFolder = objFSO.GetFolder(myFolderPath)
Set collPicturesFolders = objPicturesFolder.SubFolders
For Each indPicturesFolder in collPicturesFolders
indPicturesFolderSpaces =
Replace(indPicturesFolder.Name,"_"," ")
%>
<img src="icons/orangeball.gif" align="top">
<a href="thumb.asp?Folder=<%= indPicturesFolder.Name
%>" class="links">
<%= indPicturesFolderSpaces %></A>


<%
Next
%>
<%

Set collPicturesFolders = Nothing

Else
'The main picture folder does not exists
%>
<font class="error">No Pictures could be
found.</font>
<%
End If
%>
</td>
</tr>
</table>


Your help is kindly appreciated.


Eugene Anthony
 
E

Evertjan.

Eugene Anthony wrote on 24 mei 2006 in
microsoft.public.inetserver.asp.general:
The code bellow will display a list of folders in a directory. Now lets
say I have 20 folders, I want to display the first 10 folders, then
display another 10 folders just like the paging concept how is it done?

Just count them:

page = 3
' starting at page 0 and each page has 10 files, but for the last page
n=0
For Each indPicturesFolder in collPicturesFolders
if n>=page*10 and n<=page*10+9 then
response.write indPicturesFolder.Name & "<br>"
end if
n=n+1
next

This is basic vbs, but untested
 
E

Eugene Anthony

Is there a way to store the names into a session variable, then using
the variable apply the paging style (next, previous).

Eugene Anthony
 
E

Evertjan.

Eugene Anthony wrote on 24 mei 2006 in
microsoft.public.inetserver.asp.general:
Is there a way to store the names into a session variable, then using
the variable apply the paging style (next, previous).

What are you talking about?

Please quote what you are replying to. If you want to post a followup via
groups.google.com, don't use the "Reply" link at the bottom of the article.
Click on "show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
<http://www.safalra.com/special/googlegroupsreply/>
 
A

Anthony Jones

Eugene Anthony said:
Is there a way to store the names into a session variable, then using
the variable apply the paging style (next, previous).

There is but I'm not sure that level of complexity is required for just 20
folders. However assuming you have a lot more in a real world situation and
after some performance testing you can see that all the FSO activity would
cause the app a problem, then as an outline this is what I would do:-

Create function which builds an XML representation of the folders into a
Free Threaded DOM. Store the DOM in the Session object. Have page accept a
startIndex and itemCount query string values to specify the items needed.
The output can then access the appropriate items using syntax like this:-

If lItemCount + lStartndex > xmlDOM.documentElement.childNodes.length Then
lItemCount = xmlDOM.documentElement.childNodes.length - lStartIndex
End If

For i = lStartIndex To lStartIndex + lItemCount - 1
Set elem = xmlDOM.documentElement.childNodes(i)
' Write HTML to Response
Next

This should preform reasonably well. You could consider storing the XML in
the application object if the list is quite static and is useful to multiple
users. However in both cases you might also need to mechanism to drop them
from the application or session object when not needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,055
Members
48,769
Latest member
Clifft

Latest Threads

Top