Mitt tips är att du i stället för att loopa ut ditt objekt så lägger du in det i ett recordset, väl i ett recordset kan du behandla, läs sortera, precis hur du vill.
Tex med hjälp av en länk och en querystring kan du då lätt byta sorteringsordning samt sorteringhåll, typ fallande eller stigande.
Frågan#1
Jag har en webbmodul med några år på nacken - från 2002 - och jag behöver hjälp med kodning då jag inte får rätt. Hittelön om 500:- för den som har en lösning.
Nuläge - har filhanterare med FileSystemObject.
Dokumenten listas efter namn.
Vill ha - dokumenten skall listas efter datum och om möjligt en sorteringsfunktion för användaren.
<!--#include file="Inc/IncludeFiles.inc"-->
<!--#include file="Inc/Db_link.inc"-->
<%
SQL = "SELECT Mapp FROM Dokument_Data Where UserId = '" & Session("eDokument_UserId") & "' "
Set RS = Connection.Execute(SQL)
If RS.EOF Then
MappNamn = "Test"
Else
MappNamn = RS("Mapp")
End If
RS.Close
Set RS = Nothing
Connection.Close
Set Connection = Nothing
%>
<%
'Set this to the home directory in relationship to the script.
'You cannot have the directory set to up one directory (ie "../") for security reasons unless you disable "Security" below.
'Note that if your file home directory is up one level the script may not function properly.
HomeDir = "Filarkiv/"
HomeDir = HomeDir &"" & MappNamn & ""
'Do not put a "/" on the end of this!
'Do not edit below this line unless you know what you're doing.
Security = "On"
'If you do not want users browsing directories up one level from the specified one, set this to "On".
'Otherwise, set it to "Off"
CurrentDir = Request.QueryString("dir")
'if Left(CurrentDir, 3) = "../" or Left(CurrentDir, 3) = "/" and Security = "On" then
'Response.Write "You are not permitted to browse this directory."
'else
if Left(CurrentDir, 8) = "Filarkiv" or Left(CurrentDir, 8) = "" and Security = "On" then
Set FSO = Server.CreateObject("Scripting.FileSystemObject")
if CurrentDir = "" then
CurrentDir = HomeDir
Set BrowseContents = FSO.GetFolder(Server.MapPath(HomeDir))
else
Set BrowseContents = FSO.GetFolder(Server.MapPath(CurrentDir))
end if
Set filer = BrowseContents.Files
Set underkataloger = BrowseContents.SubFolders
Function bytesize(bytes)
If bytes < 1024 Then
bytesize = "1 kB"
Else
bytesize = FormatNumber((bytes/1024),0,-1) & " kB"
End If
End Function
' Which Columns to display (True or False)
Const DisplayColumnName = True
Const DisplayColumnSize = False
Const DisplayColumnType = False
Const DisplayColumnModified = True
Const DisplayColumnSubItems = True
%>
<font size="3" color="#700000" face="Verdana"><b>Mina filer</b></font><br><br>
<br><br>
<%
if not CurrentDir = HomeDir then
UpOneDirBegPos = InStrRev(CurrentDir, "/")
UpOneDirTotal = len(CurrentDir)
UpOneDirPath = Left(CurrentDir, UpOneDirBegPos - 1)
Response.Write "<b>«</b> <A HREF=""?ShowPage=Filer&dir=" & UpOneDirPath & """>Upp en nivå</A><br>"
end if
%>
<br>
<table border="0" cellpadding="2" cellspacing="1" width="100%" bgcolor="#bec8d2">
<tr>
<% If DisplayColumnName Then %>
<td class="list03">Namn</td>
<% End If %>
<% If DisplayColumnSize Then %>
<td class="list03">Storlek</td>
<% End If %>
<% If DisplayColumnType Then %>
<td class="list03">Typ</td>
<% End If %>
<% If DisplayColumnModified Then %>
<td class="list03">Ändrad</td>
<% End If %>
</tr>
<% for each BrowsedFolder in BrowseContents.SubFolders %>
<% if BrowsedFolder.Name <> "_vti_cnf" then %>
<tr>
<% If DisplayColumnName Then %>
<td class="list01"><IMG SRC="Pic/Icon/Icon_Prog_Folder.gif"> <A HREF="?dir=<% = CurrentDir & "/" & BrowsedFolder.Name %>&ShowPage=Filer"><% = BrowsedFolder.Name %></A></td>
<% End If %>
<% If DisplayColumnSize Then %>
<td class="list01" align="right"><% = BrowsedFolder.Size \ 1024 %> kB </td>
<% End If %>
<% If DisplayColumnType Then %>
<td class="list01">Filmapp</td>
<% End If %>
<% If DisplayColumnModified Then %>
<td class="list01"><% = FormatDateTime(BrowsedFolder.DateCreated, 2) & " " & FormatDateTime(BrowsedFolder.DateCreated, 4) %></td>
<% End If %>
</tr>
<% ContainsSomething = "True" %>
<% end if %>
<% next %>
<%
for each BrowsedFile in BrowseContents.Files
FileExtBegPos = InStrRev(BrowsedFile.Name, ".")
FileExtTotal = len(BrowsedFile.Name)
FileExt = Right(BrowsedFile.Name, FileExtTotal - FileExtBegPos)
FileExt = LCase(FileExt)
%>
<% select case FileExt
case "doc"
FileIcon = "Icon_Prog_Word.gif"
case "dot"
FileIcon = "Icon_Prog_Word_mall.gif"
case "xls"
FileIcon = "Icon_Prog_Excel.gif"
case "pdf"
FileIcon = "Icon_Prog_Acrobat.gif"
case "htm", "html", "shtm", "shtml"
FileIcon = "Icon_Prog_htm.gif"
case "jpg", "jpeg", "png", "bmp"
FileIcon = "Icon_Prog_Jpg.gif"
case "gif"
FileIcon = "Icon_Prog_Gif.gif"
case else
FileIcon = "icon.gif"
end select
%>
<tr>
<% If DisplayColumnName Then %>
<td class="list01"><img src="Pic/Icon/<% = FileIcon%>"> <A HREF="<%= CurrentDir & "/" & BrowsedFile.Name %>" target="_blank"><% = BrowsedFile.Name %></a></td>
<% End If %>
<% If DisplayColumnSize Then %>
<td class="list01" align="right"><% = bytesize(BrowsedFile.Size) %> </td>
<% End If %>
<% If DisplayColumnType Then %>
<td class="list01"><% = BrowsedFile.type %></td>
<% End If %>
<% If DisplayColumnModified Then %>
<td class="list01"><% = FormatDateTime(BrowsedFile.DateCreated, 2) & " " & FormatDateTime(BrowsedFile.DateCreated, 4)%></td>
<% End If %>
</tr>
<% ContainsSomething = "True" %>
<% next %>
</table>
<%
if ContainsSomething <> "True" then
Response.Write "<br><br><img src=""Pic/Icon/Icon_Info.gif"" alt="""" width=""13"" height=""13"" border=""0"" align=""absbottom""> Det finns inga filer i denna mapp."
end if
%>
<br>
<%
Set FSO = Nothing
Set BrowseContents = Nothing
else
Response.Redirect("SiteSecurity.asp?ShowPage=SiteSecurity&SiteSecurityAction=LeaveNow")
'Response.Write "You are not permitted to browse this directory."
end if
%>
<!--#include file="Inc/html_slut.inc"-->