URL Links in Master Page

  • Thread starter Thread starter Brett Baisley
  • Start date Start date
B

Brett Baisley

Hello,

I am having trouble figuring out URL's from my master page.

Here is my setup. I have a default.aspx and default.master file in the root
folder. I have an "images" folder with logos and css files in there. I also
have a "html" folder with more pages in there.

The default.aspx file loads find, but when I open any of the other files
under "html" folder, the linking is off therefore the logo's and css can't
be found.

I tried linking different ways:
~/images/default.gif
/images/default.gif
images/default.gif

I think the problem is when I publish to the server, I have somethink like
http://localhost/test/default.aspx so that http://localhost/test is should
be the base URL, however /images/default.gif will take you to
http://localhost/images/default.gif.

Is there a way do make this work without having to include the "test" in the
URLs? The reason I want to so it this way is because I eventually want to
have versions (ie: 0.1, 0.2, etc) and I don't want to have to change all of
the URLs in my code each time.

Thanks,
Brett
 
I am having trouble figuring out URL's from my master page.
Here is my setup. I have a default.aspx and default.master file in the
root folder. I have an "images" folder with logos and css files in there.
I also have a "html" folder with more pages in there.

The default.aspx file loads find, but when I open any of the other files
under "html" folder, the linking is off therefore the logo's and css can't
be found.

if I understand your problem correctly then probably the only possibility
would be to copy the "images" folder to the "html" folder so that you have
two copies of it - the first one referenced by pages from the root folder
and the second copy referenced by pages from the "html" folder.

I also have similar situation: a master page references several css/js
files. it works well for html pages from the same directory as the master
page. in case of html pages from other folders, the css/js files are not
loaded because they are treated as if they were referenced from the html
page (not the master page).

the solution I propose to you that involves making a copy of a resource
folder works for me. if there is another option I would be glad to learn it.
the "~/" trick does not work here because the static css/js link is not
processed on the server side.

Regards,
Wiktor Zychla
 
You need to insure that your image tag is rendered on the server:


<img src="~/Image/AndrewPix.jpg" runat="server" />

<asp:Image runat="server" ImageUrl="~/Image/AndrewPix.jpg" />
 
Thanks Andrew.

That did the trick


Andrew Robinson said:
You need to insure that your image tag is rendered on the server:


<img src="~/Image/AndrewPix.jpg" runat="server" />

<asp:Image runat="server" ImageUrl="~/Image/AndrewPix.jpg" />
 
Back
Top