SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ~ use in javascript

    javaScript.AppendFormat("buttonImage: \"{0}\",", "~/App_Themes/Images/Structure/Buttons/Icons/calendar.gif");

    ~ is showing up as is since it is inside double quotes, how can i push the full path here? This piece of javascript is inside the head section.

    Thanks
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...

  2. #2
    SitePoint Guru Jason__C's Avatar
    Join Date
    Oct 2009
    Location
    Racoon City
    Posts
    660
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tahirjadoon View Post
    javaScript.AppendFormat("buttonImage: \"{0}\",", "~/App_Themes/Images/Structure/Buttons/Icons/calendar.gif");

    ~ is showing up as is since it is inside double quotes, how can i push the full path here? This piece of javascript is inside the head section.

    Thanks
    Code ASP:
    System.Web.HttpContext.Current.Server.MapPath(~/App_Themes/Images/Structure/Buttons/Icons/calendar.gif);

  3. #3
    Chopped Liver bronze trophy imaginekitty's Avatar
    Join Date
    Aug 2007
    Location
    Pennsyltucky
    Posts
    1,494
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Options:
    1. Remove the ~ to make it relative to root
    2. Remove ~/ to make it relative to the page (if it is relative in that way)
    3. Use absolute URL

  4. #4
    SitePoint Author silver trophybronze trophy
    wwb_99's Avatar
    Join Date
    May 2003
    Location
    Washington, DC
    Posts
    10,629
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Don't use mappath -- you don't need the server-side file mapping. What you want to use would be either Control.ResolveUrl() or Url.Content() if you are on MVC.

  5. #5
    Learning...
    Join Date
    Jan 2003
    Posts
    778
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks guys.

    wwb_99: i am using ResolveClientUrl and it worked for me. Hope i am not breaking any thing classic .net rules (don't have much experience with classic .net).

    This was on the CMS side and we are using Kentico .
    The beauty of life is not dependent on how happy you are,
    but on how happy others can be because of you...


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
  •