PhysicalApplicationPath in <script> tag

  • Thread starter Thread starter cousto D
  • Start date Start date
C

cousto D

<link
href="<%Response.Write(Request.PhysicalApplicationPath)%>/css/toolbar.cs
s" type="text/css" rel="stylesheet" >

This work fine
but the same trix doesn't work into <script> tag like this:
<script language="JavaScript" src="../js/javascript.js"></script>

i tryed replacing src attribut by:
src="<%Response.Write(Request.PhysicalApplicationPath)%>/js/javascript.j
s"></script>

Any tought about how to set a somewhat relative path to the src
attribute

thanks
cousTo
 
Hi

Request.PhysicalApplicationPath return a path like "c:\inetpub\wwwroot\"
However "scr" attribute of Script specifies the location of an external script which requires to be a URL that is accessible on the server. It should be like "http:\\Server\script.js" so that it could be included when response back to the client

Bin Song, MCP
 
So then you'll probably want to write
src="<%Server.MapPath("/js/javascript.js");%>"

cheers,
mortb
 
Back
Top