CodeAve.com CodeAve.com - ASP - Read/Write
ASP
·Read/Write
·Script Writers
·Database Display
·Response Objects
·Server Variables
·Random Events
·Articles
·Miscellaneous
·Contents
·What's New?
JavaScript
CSS
HTML
Maps
Links
Mail List
Search
Sitemap


 


File Exists
Most of the links that are generated from a db are targeted back into the db, however there are times when the output from a db may be linked to a file completely independent of the input db file.  To ensure that the file you're linking to actually exists asp can check it by utilizing fileexists.  The following example first checks for a page we know exists (the CodeAve.com homepage - or any page in the parent directory named index.asp) and then for a page that does not exist (variable name u_file).  Only pages found to be on the server will be linked.
View the Output
Text View
Print View
Mail this Link
Download the Code

Example of a successful match 
<br>
<%
' u_file must be the relative address from asp file being used to display the info

u_file="../index.asp"

set fso = createobject("scripting.filesystemobject")

' This will check to see if the parent directory has an index.asp page in its directory
' if so it will hyper-link it
if fso.FileExists (server.mappath(u_file)) then 
Response.Write "Click <a href='"& u_file &"'>here</a>"
else 
Response.Write u_file
end if
%>


<p>&nbsp</p>
Example of a unsuccessful match <br>

<%
' u_file must be the relative address from asp file being used to display the info

u_file="any_file_name_that_may_or_may_not_be_there.asp"

set fso = createobject("scripting.filesystemobject")

' This will check to see if the parent directory has the "u_file" page in its directory
' if so it will hyper-link it
if fso.FileExists (server.mappath(u_file)) then 
Response.Write "Click <a href='"& u_file &"'>here</a>"
else 
Response.Write u_file
end if
%>

 

 

 



ASP: What's New? | Articles | Script Writers | Database Display | Read/Write
Server Variables | Response Objects | Random Events | Miscellaneous
HTML: Forms | Hyperlinks | Headers | Tables | Hyperlinks | Headers | Text Display
JavaScript: Document Info | Forms | Images | Navigation | Script Writers
CSS: Basics | Page Display | Text Display | Script Writers | Miscellaneous
  • 2014 michael kors
  • air max women 2013
  • 2014 michael kors
  • air max 2014
  • oakley glasses
  • oakley glasses

  • Maps: Map Script Writers | Bing Maps | Google Maps
  • bottes fr
  • ugg boot
  • Privacy Statement

    CodeAve.com is hosted by MyHosting.com
    Donate Food Online with a Mouse Click at TheHungerSite.com
    Donate Land Online with a Mouse Click at TheRainForestSite.com
    © 1999 - 2017 CodeAve.com
    All Rights Reserved

  • Kids jordan 6 rings
  • Jordan retro 10
  • Jordan retro 3