Martin Cotterill
asked on
Get the current page's filename
Hi Experts
Is there an easy way to get the filename of the current page. The reason I ask this is that I use the same piece of code on many different pages and this would make life a little easier and be a lot more forgiving of my increasing 'senior moments'.
It has to fit in with the existing code, which is:
<%
' Automatically populate link with filename by B_Dorsey at Experts Exchange
' https://www.experts-exchange.com/questions/22148871/Automatically-populate-link-with-filename.html?cid=239#18465161
' incorperating a script to find and replace cr/lf with HTML line breaks by b0lsc0tt also at EE
' https://www.experts-exchange.com/questions/22127810/Replace-cr-lf-in-ASP.html#18343873
' Using Multiple RegExp statements by B_Dorsey at Experts Exchange
' https://www.experts-exchange.com/questions/22396646/Multiple-RegExp-statements.html
' If you use this code (or any part of it) please keep this header intact.
' These guys did the work, they deserve the credit. Many thanks.
Dim objRegExp
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<id=([^>]+)+>" ' Populate Link
sContent = Replace(rsContent.Fields.I tem("Conte nt").Value , vbcrlf, "<br />") ' Find & replace
sContent = objRegExp.Replace(sContent , "<div id=more><a href=DonationsAndFundraisi ng.asp?id= $1 class=more>[ Find out more ]</a></div>")
' Multiple RegExp
sContent = Replace(sContent,"'","' ;")
sContent = Replace(sContent,"<charity Name>",(rs CharityDet ails.Field s.Item("Ch arityName" ).Value))
sContent = Replace(sContent,"<b>","<b class='contentHead'>")
' End of Multiple RegExp
response.write sContent
Set objRegExp = Nothing
%>
The filename code will replace the filename in the line:
sContent = objRegExp.Replace(sContent , "<div id=more><a href=DonationsAndFundraisi ng.asp?id= $1 class=more>[ Find out more ]</a></div>")
which, in this case, is:
'DonationsAndFundraising'
All the filenames that will be used have the '.asp' extension.
Warm regards
Martin
Is there an easy way to get the filename of the current page. The reason I ask this is that I use the same piece of code on many different pages and this would make life a little easier and be a lot more forgiving of my increasing 'senior moments'.
It has to fit in with the existing code, which is:
<%
' Automatically populate link with filename by B_Dorsey at Experts Exchange
' https://www.experts-exchange.com/questions/22148871/Automatically-populate-link-with-filename.html?cid=239#18465161
' incorperating a script to find and replace cr/lf with HTML line breaks by b0lsc0tt also at EE
' https://www.experts-exchange.com/questions/22127810/Replace-cr-lf-in-ASP.html#18343873
' Using Multiple RegExp statements by B_Dorsey at Experts Exchange
' https://www.experts-exchange.com/questions/22396646/Multiple-RegExp-statements.html
' If you use this code (or any part of it) please keep this header intact.
' These guys did the work, they deserve the credit. Many thanks.
Dim objRegExp
Set objRegExp = New RegExp
objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<id=([^>]+)+>" ' Populate Link
sContent = Replace(rsContent.Fields.I
sContent = objRegExp.Replace(sContent
' Multiple RegExp
sContent = Replace(sContent,"'","'
sContent = Replace(sContent,"<charity
sContent = Replace(sContent,"<b>","<b
' End of Multiple RegExp
response.write sContent
Set objRegExp = Nothing
%>
The filename code will replace the filename in the line:
sContent = objRegExp.Replace(sContent
which, in this case, is:
'DonationsAndFundraising'
All the filenames that will be used have the '.asp' extension.
Warm regards
Martin
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi ryancys
That get the directory and filename.
How would I cut it down to get just the filename?
Regards
Martin
That get the directory and filename.
How would I cut it down to get just the filename?
Regards
Martin
ASKER
Hello again ryancys
Our posts crossed but your second post did the trick.
Absolutely brilliant!
Many thanks. That's helped me no end.
Warm regards
Martin
Our posts crossed but your second post did the trick.
Absolutely brilliant!
Many thanks. That's helped me no end.
Warm regards
Martin
Glad could make some help here, cheers :^)
try:
response.write request.ServerVariables("S
?