SitePoint Sponsor

User Tag List

Results 1 to 13 of 13
  1. #1
    @alexstanford Alex's Avatar
    Join Date
    Apr 2004
    Location
    Jacksonville, Florida
    Posts
    759
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    ASP.NET Beginner Questions...

    Hello everyone,

    I'm just beginning to work with ASP.NET and I've run into some issues that I can't seem to solve.

    I'm building the master page for a site that can be viewed here: www.cisp.com

    The master page has the following javascript includes in the head tag:

    Code:
        <script type="text/javascript" src="/cisp.net/js/jquery-1.3.2.min.js"></script>
        <script type="text/javascript" src="/cisp.net/js/jquery.accordion-1.2.1.js"></script>
        <script type="text/javascript" src="/cisp.net/js/thickbox-compressed.js"></script>
    As you can see, I've had to reference these documents using the "/cisp.net/js/" path in order to get them to properly function across multiple directories.

    If I use a path like "~/js/..." or "/js/..." or "js/..." the javascript will either not be pulled into the page at all, or it will only be pulled into root pages and not pages sitting within other directories.

    I need to find a way to dynamically hit these from any directory in my website. These files are to be called across all pages of my site, so it would be senseless to not use a master page.

    Can anyone lend some assistance?
    Alex Stanford @alexstanford tumblog about.me in fb G+ K
    TechTalkin The Premier Community for Technology Enthusiasts and Professionals
    Full Ambit Media Zero Sacrifice Web Design & Development; Made in the USA @fullambit in fb G+ K

  2. #2
    SitePoint Member
    Join Date
    Oct 2008
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just switch to PHP .lol

  3. #3
    @alexstanford Alex's Avatar
    Join Date
    Apr 2004
    Location
    Jacksonville, Florida
    Posts
    759
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thank you for that useless post, but you'll need to get with the company I work for to discuss that, I have no play in such a decision.

    Issue solved.
    Alex Stanford @alexstanford tumblog about.me in fb G+ K
    TechTalkin The Premier Community for Technology Enthusiasts and Professionals
    Full Ambit Media Zero Sacrifice Web Design & Development; Made in the USA @fullambit in fb G+ K

  4. #4
    SitePoint Guru pufa's Avatar
    Join Date
    Oct 2004
    Location
    Portugal, Lisboa
    Posts
    947
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    /js/jquery-1.3.2.min.js should work if cisp.net is your application root.
    Ciao, Rui...

  5. #5
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by pufa View Post
    /js/jquery-1.3.2.min.js should work if cisp.net is your application root.
    That's how I always do it.

  6. #6
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,868
    Mentioned
    37 Post(s)
    Tagged
    0 Thread(s)
    One thing to take note of is it depends how ur local environment is set up. /js/jquery doesnt work on my dev site, but it does work on live site. Even tho locally the site folder is the app root.

  7. #7
    @alexstanford Alex's Avatar
    Join Date
    Apr 2004
    Location
    Jacksonville, Florida
    Posts
    759
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    NightStalker is entirely correct. The issue revolved around how the local web server in Visual Studio was running.

    Once I changed the virtual path from "/asp.net" to "/" the application pulled the JavaScript properly. Quite stupid of Visual Studio imho.

    Alex
    Alex Stanford @alexstanford tumblog about.me in fb G+ K
    TechTalkin The Premier Community for Technology Enthusiasts and Professionals
    Full Ambit Media Zero Sacrifice Web Design & Development; Made in the USA @fullambit in fb G+ K

  8. #8
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,576
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Not really--it is all on the developer to get the URLs correctly root relative. See this post for two techniques.

  9. #9
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,868
    Mentioned
    37 Post(s)
    Tagged
    0 Thread(s)
    That is true. But in my case I was not using VS server i was also using IIS, but still had the same issue.

  10. #10
    SitePoint Enthusiast dnectom's Avatar
    Join Date
    Dec 2005
    Location
    Lincolnshire, Uk
    Posts
    37
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just set the baseref of the page and then work out where the directory is from based upon this baseref

  11. #11
    SitePoint Member
    Join Date
    May 2009
    Posts
    9
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why dont you use ../ to reach the root director them mention the folder then the file like ../Scripts/Validator.js like that it can work.

  12. #12
    SitePoint Mentor NightStalker-DNS's Avatar
    Join Date
    Jul 2004
    Location
    Cape Town, South Africa
    Posts
    2,868
    Mentioned
    37 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by phoenixtears
    why dont you use ../ to reach the root director them mention the folder then the file like ../Scripts/Validator.js like that it can work.
    because the same master page would be used for files in the root as well, then that path will be incorrect

  13. #13
    SitePoint Enthusiast
    Join Date
    Jul 2005
    Posts
    41
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could also:

    Code:
    <script type="text/javascript" src="<%= Page.ResolveUrl("~/cisp.net/js/jquery-1.3.2.min.js") %>"></script>
    I suppose you could even wrap it in a custom control and have something like this instead:

    Code:
    <ns:ScriptReference Path="~/cisp.net/js/jquery-1.3.2.min.js" />


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •