0

I have a User Control with several images inside. I will set images sources from a main directory like "Website\Pictures".

My User Control is located in a specific directory like this: "Website\UControls" (Template Source Directory)

I'm trying to Load my user control inside a div in another page. Everything will work OK but images sources. I will see user control's Template Source Directory at the beginning of every image and it cause to have broken links.

For example an image source should be like this: "../Pictures/1.png", but I will have this: "../UControls/Pictures/1.png" where "UControls" is Template Source Directory.

How can I avoid such treating?

Inside Man
  • 4,194
  • 12
  • 59
  • 119

1 Answers1

0

You should use ~ operator as a sign of the root your site.

See this answer as an example getting base url of web site's root (absolute/relative url)


Seems my original answer is irrelevant to the problem. Please try with leading slash as in https://msdn.microsoft.com/en-us/library/ms178116.aspx in the part

<img src="/Images/SampleImage.jpg" />

If the URL of your Web site is http://www.contoso.com, the path would resolve to the following: http://www.contoso.com/Images/SampleImage.jpg

Community
  • 1
  • 1
VMykyt
  • 1,589
  • 12
  • 17
  • I know this, everything will be OK. but after loading User Control inside another control, it will automatically add its Template Source Directory into images' urls – Inside Man Dec 28 '15 at 12:20