using the ~/ path with script files?

Discussion in 'ASP .Net' started by Milsnips, Jan 31, 2007.

  1. Milsnips

    Milsnips Guest

    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.
     
    Milsnips, Jan 31, 2007
    #1
    1. Advertising

  2. 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
     
    Laurent Bugnion [MVP], Jan 31, 2007
    #2
    1. Advertising

  3. Milsnips

    Milsnips Guest

    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]" <> wrote in message
    news:...
    > 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
     
    Milsnips, Jan 31, 2007
    #3
  4. 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
     
    Laurent Bugnion [MVP], Jan 31, 2007
    #4
  5. Hi there,

    Try this one:

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

    or in master page load event

    Page.ClientScript.RegisterClientScriptInclude("timerScript",
    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]" <> wrote in message
    > news:...
    > > 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

    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Jan 31, 2007
    #5
  6. Milsnips

    Mark Rae Guest

    "Milosz Skalecki [MCAD]" <> wrote in message
    news:...

    > <script language="javascript"


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

    <script type="text/javascript"
     
    Mark Rae, Jan 31, 2007
    #6
  7. OK OK Mark, i focused on src attribute :D
    --
    Milosz


    "Mark Rae" wrote:

    > "Milosz Skalecki [MCAD]" <> wrote in message
    > news:...
    >
    > > <script language="javascript"

    >
    > That's deprecated syntax - you shouldn't be advising people to use it...
    >
    > <script type="text/javascript"
    >
    >
    >
     
    =?Utf-8?B?TWlsb3N6IFNrYWxlY2tpIFtNQ0FEXQ==?=, Jan 31, 2007
    #7
  8. 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 :D
    > --
    > Milosz
    >
    >
    > "Mark Rae" wrote:
    >
    > > "Milosz Skalecki [MCAD]" <> wrote in message
    > > news:...
    > >
    > > > <script language="javascript"

    > >
    > > That's deprecated syntax - you shouldn't be advising people to use it...
    > >
    > > <script type="text/javascript"
    > >
    > >
    > >
     
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, Feb 1, 2007
    #8
  9. Milsnips

    Milsnips Guest

    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]" <> wrote in message
    news:...
    > Hi there,
    >
    > Try this one:
    >
    > <script language="javascript"
    > src="<%=ResolveClientUrl("~/scripts/timer.js")
    > %"></script>
    >
    > or in master page load event
    >
    > Page.ClientScript.RegisterClientScriptInclude("timerScript",
    > 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]" <> wrote in message
    >> news:...
    >> > 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

    >>
    >>
    >>
     
    Milsnips, Feb 2, 2007
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mupota Muchelemba
    Replies:
    1
    Views:
    943
    Tony Morris
    Feb 4, 2004
  2. Rajat
    Replies:
    3
    Views:
    730
    Jorgen Grahn
    Jan 8, 2010
  3. dude
    Replies:
    5
    Views:
    1,760
    Jussi Piitulainen
    Mar 17, 2011
  4. Salman
    Replies:
    0
    Views:
    125
    Salman
    Feb 26, 2005
  5. \A_Michigan_User\

    Various path/path/files.asp all #include this 1 file

    \A_Michigan_User\, Jul 10, 2005, in forum: ASP General
    Replies:
    1
    Views:
    251
    Jeff Cochran
    Jul 10, 2005
Loading...

Share This Page