Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > using the ~/ path with script files?

Reply
Thread Tools

using the ~/ path with script files?

 
 
Milsnips
Guest
Posts: n/a
 
      01-31-2007
hi there,

i'm currently using the following line:

<script language="javascript" type="text/javascript"
src="../scripts/timer.js"></script>

but i want to do the following, as the script needs to be used in many pages
at varios folder depths ( it is placed in my master page).

<script language="javascript" type="text/javascript"
src="~/scripts/timer.js"></script>

doesnt ASP.NET 2.0 pick up that i've put the "~/" symbol in the script SRC
parameter, as it only works on the pages within the SRC root "../" which im
currently using.

any help appreciated.

thanks,
Paul.


 
Reply With Quote
 
 
 
 
Laurent Bugnion [MVP]
Guest
Posts: n/a
 
      01-31-2007
Hi,

Milsnips wrote:
> hi there,
>
> i'm currently using the following line:
>
> <script language="javascript" type="text/javascript"
> src="../scripts/timer.js"></script>


The "language" attribute has been deprecated, and you should remove it.

>
> but i want to do the following, as the script needs to be used in many pages
> at varios folder depths ( it is placed in my master page).
>
> <script language="javascript" type="text/javascript"
> src="~/scripts/timer.js"></script>


<script type="text/javascript"
src="/scripts/timer.js"></script>

This looks for the "scripts" folder at the root of the website.

HTH,
Laurent

>
> doesnt ASP.NET 2.0 pick up that i've put the "~/" symbol in the script SRC
> parameter, as it only works on the pages within the SRC root "../" which im
> currently using.
>
> any help appreciated.
>
> thanks,
> Paul.

--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
 
 
 
Milsnips
Guest
Posts: n/a
 
      01-31-2007
hi Laurent,

it isnt solving my problem, this is the folder heirarchy i have, and where
my javascript works and doesnt


ROOT
SCRIPTS/
timer.js
TEMPLATES/
main.master - with following line: <script
type="text/javascript" src="../scripts/timer.js"></script>
EN/
projects.aspx - javascript works on this file.
PROJECTS/
active.aspx - javascript DOESNT work here..
completed.aspx - javascript also DOESNT work here..


I hope you understand the folder heirarchy i;ve done, the BOLD items are
folders

regards,
Paul

"Laurent Bugnion [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> Milsnips wrote:
>> hi there,
>>
>> i'm currently using the following line:
>>
>> <script language="javascript" type="text/javascript"
>> src="../scripts/timer.js"></script>

>
> The "language" attribute has been deprecated, and you should remove it.
>
>>
>> but i want to do the following, as the script needs to be used in many
>> pages at varios folder depths ( it is placed in my master page).
>>
>> <script language="javascript" type="text/javascript"
>> src="~/scripts/timer.js"></script>

>
> <script type="text/javascript"
> src="/scripts/timer.js"></script>
>
> This looks for the "scripts" folder at the root of the website.
>
> HTH,
> Laurent
>
>>
>> doesnt ASP.NET 2.0 pick up that i've put the "~/" symbol in the script
>> SRC parameter, as it only works on the pages within the SRC root "../"
>> which im currently using.
>>
>> any help appreciated.
>>
>> thanks,
>> Paul.

> --
> Laurent Bugnion [MVP ASP.NET]
> Software engineering: http://www.galasoft-LB.ch
> PhotoAlbum: http://www.galasoft-LB.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch



 
Reply With Quote
 
Laurent Bugnion [MVP]
Guest
Posts: n/a
 
      01-31-2007
Hi,

Milsnips wrote:
> hi Laurent,
>
> it isnt solving my problem, this is the folder heirarchy i have, and where
> my javascript works and doesnt
>
>
> ROOT
> SCRIPTS/
> timer.js
> TEMPLATES/
> main.master - with following line: <script
> type="text/javascript" src="../scripts/timer.js"></script>


I think I suggested src="/scripts/timer.js"

The masterpage is a control. The path to the "scripts" folder is
relative to the page (ASPX), *not* to the master.

My suggestion is an absolute path pointing to the "scripts" folder in
the website root. I still think it should work.

HTH,
Laurent

> EN/
> projects.aspx - javascript works on this file.
> PROJECTS/
> active.aspx - javascript DOESNT work here..
> completed.aspx - javascript also DOESNT work here..
>
>
> I hope you understand the folder heirarchy i;ve done, the BOLD items are
> folders
>
> regards,
> Paul

--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      01-31-2007
Hi there,

Try this one:

<script language="javascript" src="<%=ResolveClientUrl("~/scripts/timer.js")
%"></script>

or in master page load event

Page.ClientScript.RegisterClientScriptInclude("tim erScript",
ResolveClientUrl("~/scripts/timer.js"));


--
Milosz


"Milsnips" wrote:

> hi Laurent,
>
> it isnt solving my problem, this is the folder heirarchy i have, and where
> my javascript works and doesnt
>
>
> ROOT
> SCRIPTS/
> timer.js
> TEMPLATES/
> main.master - with following line: <script
> type="text/javascript" src="../scripts/timer.js"></script>
> EN/
> projects.aspx - javascript works on this file.
> PROJECTS/
> active.aspx - javascript DOESNT work here..
> completed.aspx - javascript also DOESNT work here..
>
>
> I hope you understand the folder heirarchy i;ve done, the BOLD items are
> folders
>
> regards,
> Paul
>
> "Laurent Bugnion [MVP]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> >
> > Milsnips wrote:
> >> hi there,
> >>
> >> i'm currently using the following line:
> >>
> >> <script language="javascript" type="text/javascript"
> >> src="../scripts/timer.js"></script>

> >
> > The "language" attribute has been deprecated, and you should remove it.
> >
> >>
> >> but i want to do the following, as the script needs to be used in many
> >> pages at varios folder depths ( it is placed in my master page).
> >>
> >> <script language="javascript" type="text/javascript"
> >> src="~/scripts/timer.js"></script>

> >
> > <script type="text/javascript"
> > src="/scripts/timer.js"></script>
> >
> > This looks for the "scripts" folder at the root of the website.
> >
> > HTH,
> > Laurent
> >
> >>
> >> doesnt ASP.NET 2.0 pick up that i've put the "~/" symbol in the script
> >> SRC parameter, as it only works on the pages within the SRC root "../"
> >> which im currently using.
> >>
> >> any help appreciated.
> >>
> >> thanks,
> >> Paul.

> > --
> > Laurent Bugnion [MVP ASP.NET]
> > Software engineering: http://www.galasoft-LB.ch
> > PhotoAlbum: http://www.galasoft-LB.ch/pictures
> > Support children in Calcutta: http://www.calcutta-espoir.ch

>
>
>

 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      01-31-2007
"Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> <script language="javascript"


That's deprecated syntax - you shouldn't be advising people to use it...

<script type="text/javascript"


 
Reply With Quote
 
=?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=
Guest
Posts: n/a
 
      01-31-2007
OK OK Mark, i focused on src attribute
--
Milosz


"Mark Rae" wrote:

> "Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
> > <script language="javascript"

>
> That's deprecated syntax - you shouldn't be advising people to use it...
>
> <script type="text/javascript"
>
>
>

 
Reply With Quote
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      02-01-2007
Never mind what Mark said. I liked it!
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net




"Milosz Skalecki [MCAD]" wrote:

> OK OK Mark, i focused on src attribute
> --
> Milosz
>
>
> "Mark Rae" wrote:
>
> > "Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> >
> > > <script language="javascript"

> >
> > That's deprecated syntax - you shouldn't be advising people to use it...
> >
> > <script type="text/javascript"
> >
> >
> >

 
Reply With Quote
 
Milsnips
Guest
Posts: n/a
 
      02-02-2007
Thanks Milosz,

thats just the kind of solution i was looking for, and it works great!
Thanks to all the resfponses rom the others also

regards,
Paul
"Milosz Skalecki [MCAD]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi there,
>
> Try this one:
>
> <script language="javascript"
> src="<%=ResolveClientUrl("~/scripts/timer.js")
> %"></script>
>
> or in master page load event
>
> Page.ClientScript.RegisterClientScriptInclude("tim erScript",
> ResolveClientUrl("~/scripts/timer.js"));
>
>
> --
> Milosz
>
>
> "Milsnips" wrote:
>
>> hi Laurent,
>>
>> it isnt solving my problem, this is the folder heirarchy i have, and
>> where
>> my javascript works and doesnt
>>
>>
>> ROOT
>> SCRIPTS/
>> timer.js
>> TEMPLATES/
>> main.master - with following line: <script
>> type="text/javascript" src="../scripts/timer.js"></script>
>> EN/
>> projects.aspx - javascript works on this file.
>> PROJECTS/
>> active.aspx - javascript DOESNT work here..
>> completed.aspx - javascript also DOESNT work
>> here..
>>
>>
>> I hope you understand the folder heirarchy i;ve done, the BOLD items are
>> folders
>>
>> regards,
>> Paul
>>
>> "Laurent Bugnion [MVP]" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Hi,
>> >
>> > Milsnips wrote:
>> >> hi there,
>> >>
>> >> i'm currently using the following line:
>> >>
>> >> <script language="javascript" type="text/javascript"
>> >> src="../scripts/timer.js"></script>
>> >
>> > The "language" attribute has been deprecated, and you should remove it.
>> >
>> >>
>> >> but i want to do the following, as the script needs to be used in many
>> >> pages at varios folder depths ( it is placed in my master page).
>> >>
>> >> <script language="javascript" type="text/javascript"
>> >> src="~/scripts/timer.js"></script>
>> >
>> > <script type="text/javascript"
>> > src="/scripts/timer.js"></script>
>> >
>> > This looks for the "scripts" folder at the root of the website.
>> >
>> > HTH,
>> > Laurent
>> >
>> >>
>> >> doesnt ASP.NET 2.0 pick up that i've put the "~/" symbol in the script
>> >> SRC parameter, as it only works on the pages within the SRC root "../"
>> >> which im currently using.
>> >>
>> >> any help appreciated.
>> >>
>> >> thanks,
>> >> Paul.
>> > --
>> > Laurent Bugnion [MVP ASP.NET]
>> > Software engineering: http://www.galasoft-LB.ch
>> > PhotoAlbum: http://www.galasoft-LB.ch/pictures
>> > Support children in Calcutta: http://www.calcutta-espoir.ch

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute a script from another script and other script does notdo busy wait. Rajat Python 3 01-08-2010 02:05 PM
RE: How to execute a script from another script and other script doesnotdo busy wait. VYAS ASHISH M-NTB837 Python 2 01-07-2010 08:18 PM
Server.MapPath() croaking with "failed to map path", but path is legal awbacker@gmail.com ASP .Net 0 05-12-2005 10:50 PM
Bizzare: Invalid path to Access mdb, path is good Keith-Earl ASP .Net 1 05-03-2004 03:25 PM
Tomcat returning 404 error when using additional path (/servlet/myServlet/extra/path/info) Mupota Muchelemba Java 1 02-04-2004 12:43 AM



Advertisments