KevinM
01-26-2006, 07:28 AM
On an index.asp or aspx page I need to capture the last part of the current url path (after the final slash)
e.g.
Http://www.myweb/myfolder/mysub
In this case it's 'mysub' I need to get, bearing in mind the number of slashes before it may no be known.
I'm sure there's an easy way using instr or instrRev which I could never get my head round in vb
Many Thanks
Sergeant
01-26-2006, 07:40 AM
=Mid(MyURL, InStrRev(MyURL, "/") + 1)
KevinM
01-26-2006, 08:08 AM
EDIT
Thanks, but i'm getting the current 'index.asp' rather than the folder name from my code...
I guess it should re-phrase it to 'second to last' '/'
So...
From
Http://www.myweb/myfolder/mysub/index.asp
I need just 'mysub'
Dim strCurrentURL
Dim strAlias
strCurrentURL = Request.ServerVariables("SERVER_NAME") _
& Request.ServerVariables("URL")
strAlias=Mid(strCurrentURL , InStrRev(strCurrentURL, "/") + 1)
Response.Write(strCurrentURL) & "<br>"
Response.Write(strAlias) & "<br>"
Cheers
KevinM
01-26-2006, 08:26 AM
OK SORTED.
Just found this Function...
Function GetThisPath()
aPath = Request.ServerVariables("Path_Info")
pathArr = Split(aPath, "/")
For i = 1 to uBound(pathArr) - 1 'Offset page Name
'Loop thru path and return current directory only
GetThisPath = pathArr(i)
Next
IF GetThisPath = "" Then
GetThisPath = "/" 'We are at the Root level
End IF
End Function
This is from a 'breadcrumbs' routine which extracts the 'final folder' only
split on the /
strCurrentURL=split(request.servervariables("URL"),"/")
ThisFolder=strCurrentURL(ubound(strCurrentURL)-1)
Sergeant
01-26-2006, 11:43 AM
You see, that's why Kodo's my hero.