Mapping a Virtual Path

Last post 02-14-2006 4:32 PM by dfribley. 2 replies.

Sort Posts:

  • Mapping a Virtual Path

    02-14-2006, 4:12 PM
    • Member
      122 point Member
    • dfribley
    • Member since 12-06-2005, 9:55 AM
    • Posts 25

    "HI Everybody"

    I have a quick question on how to map a virtual path from the current page.  Basically, in a master page, I add a javascript file reference:

    Page.ClientScript.RegisterClientScriptInclude(Page.GetType(), "commonLib.js", "../scripts/commonLib.js")

    How can I map the ../scripts/file.js string to the appropriate directory, no matter which page is being viewed?  I've tried "~/App/scripts", but since the parameter is a string itself, it doesn't get processed to the appropriate directory.

    Thank you for your help!!
    -Dave Fribley

  • Re: Mapping a Virtual Path

    02-14-2006, 4:18 PM
    • All-Star
      30,697 point All-Star
    • StrongTypes
    • Member since 12-13-2005, 4:21 PM
    • California
    • Posts 6,007
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Have you tried /scripts/commonLib.js? That should work.

    HTH

    Ryan Olshan
    ASPInsider | Microsoft MVP, ASP.NET
    http://ryanolshan.com

    How to ask a question
  • Re: Mapping a Virtual Path

    02-14-2006, 4:32 PM
    • Member
      122 point Member
    • dfribley
    • Member since 12-06-2005, 9:55 AM
    • Posts 25

    Hi HTH:

    hmm. Yes, that would make the most sense - wouldn't it.  I guess the reason I overlooked that option was because I'm developing in one environment and deploying in another.  '/scripts/commonLib.js' would work in my development environment, but not production.

    After I posted my original comment, I thought of doing this:

    Page.ClientScript.RegisterClientScriptInclude(Page.GetType(), "commonLib.js", Request.ApplicationPath & "/App/scripts/commonLib.js")

    I haven't tried my code yet in production, but I don't see why this wouldn't do what I need.  Thanks for your help!

    -Dave Fribley

Page 1 of 1 (3 items)