~ 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


System.Web.HttpContext.Current.Server.MapPath(“~/App_Themes/Images/Structure/Buttons/Icons/calendar.gif“);

Options:

  1. Remove the ~ to make it relative to root[]Remove ~/ to make it relative to the page (if it is relative in that way)[]Use absolute URL

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.

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 (:.