473,287 Members | 1,413 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,287 software developers and data experts.

Problem with an IMG from a Master Page

This seems like it should be so simple but I really can't figure out what's
going on:

I have a simple MasterPage. On that page I want to place an Image (IMG or
asp:Image, doesn't really matter to me). But for some reason, the image won't
come up because the path (src) for that image in the actual page displayed
isn't right. In the "src," I've tried using a path that starts with the "~"
(src="~/Shared/Images/xyz.jpg") and a path that is relative to the MasterPage
(src="../Images/xyz.jpg"). In both cases, I just don't get the right path at
output. The IMG tag is set as runat="server" and all that so I just can't
figure out what's going wrong here.

I'm starting to think that this has to do with the path of the actual page
displayed as opposed to the path from the MasterPage but that doesn't really
make a lot of sense either. Any thoughts?

Alex
May 12 '06 #1
3 1422
Alex Maghen wrote:
This seems like it should be so simple but I really can't figure out what's
going on:

I have a simple MasterPage. On that page I want to place an Image (IMG or
asp:Image, doesn't really matter to me). But for some reason, the image won't
come up because the path (src) for that image in the actual page displayed
isn't right. In the "src," I've tried using a path that starts with the "~"
(src="~/Shared/Images/xyz.jpg") and a path that is relative to the MasterPage
(src="../Images/xyz.jpg"). In both cases, I just don't get the right path at
output. The IMG tag is set as runat="server" and all that so I just can't
figure out what's going wrong here.

I'm starting to think that this has to do with the path of the actual page
displayed as opposed to the path from the MasterPage but that doesn't really
make a lot of sense either. Any thoughts?

Alex


Using ~ will bring you to the application root, so if you use an
asp:image with the image url set to "~/images/xxx.jpg" that should point
to application root/images/xxx.jpg.
May 12 '06 #2
> (IMG or asp:Image, doesn't really matter to me).

That's exactly the issue, an asp image control will handle virtual folders
having ~/...

"Ray Booysen" <rj***********@rjb.za.net> schreef in bericht
news:Oo****************@TK2MSFTNGP05.phx.gbl...
Alex Maghen wrote:
This seems like it should be so simple but I really can't figure out
what's going on:

I have a simple MasterPage. On that page I want to place an Image (IMG or
asp:Image, doesn't really matter to me). But for some reason, the image
won't come up because the path (src) for that image in the actual page
displayed isn't right. In the "src," I've tried using a path that starts
with the "~" (src="~/Shared/Images/xyz.jpg") and a path that is relative
to the MasterPage (src="../Images/xyz.jpg"). In both cases, I just don't
get the right path at output. The IMG tag is set as runat="server" and
all that so I just can't figure out what's going wrong here. I'm starting
to think that this has to do with the path of the actual page displayed
as opposed to the path from the MasterPage but that doesn't really make a
lot of sense either. Any thoughts?

Alex


Using ~ will bring you to the application root, so if you use an asp:image
with the image url set to "~/images/xxx.jpg" that should point to
application root/images/xxx.jpg.

May 14 '06 #3
Hi Alex,

Thank you for posting!

I've found a detailed article regarding how to reference images in master
pages:

#Master Pages: Master Your Site Design with Visual Inheritance and Page
Templates
http://msdn.microsoft.com/msdnmag/is...20MasterPages/

Search for the "Details of Usage" part.

Either using root path reference syntax or still using relative path, the
key is to use server-side controls.

Hope this helps.
Regards,

Walter Wang
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

May 18 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Raphael Gluck | last post by:
Hi Everyone I am having some problems with a master detail page i have set up to catalogue brochures from my site. On my master page www.tripakltd.com/brochures.asp users are invited to select...
1
by: PCH | last post by:
Hello all, Been messing the the dec CTP of .net 2 Heres the situation: I have a master page with the contents control and a button control (call it btnRefresh). I have a child page that...
7
by: Martijn Saly | last post by:
Hi there, I've created a master page with some controls on it, a Calendar control among others. Now depending on the date(s) selected, the content page needs to be updated. In the masterpage...
0
by: Nick Stansbury | last post by:
I'm experiencing a weird problem with master pages in VS 2005 - in short when the master page is open in design view in visual studio all other webforms that use that master display correctly when...
1
by: yoknows | last post by:
Hello .Net Gurus. This is my first post here so I apologize in advance if I have not provided the right information. I hope someone has seen this problem before and can tell me what I am doing...
3
by: aldonnelley | last post by:
Hi all. Just having a weird problem with tkinter. I'm trying to make a gui that shows results from an image search, with a "forward" and "back" button so the user can compare results from...
2
by: Griff | last post by:
Hi I have a web page (content.aspx) that inherits from a master page (MasterPage.master). The master page has a control (which has to be on every web page, hence on the master page)...
5
by: LamSoft | last post by:
I've got some problem on some form submit problem. In a master page, there is a form tag with the "runat=server" attribute, and a ID called "myForm". In the contentPlaceHolder under that...
5
by: xlar54 | last post by:
I have a very simple 2.0 website (framework), that uses a master page...not. I added the default.aspx page as a webcontent form, with the master page as it's master page, but the master page is...
1
by: hemantkamb | last post by:
Hi…. I have created one website with Master and content page . I have taken TreeView Control on master page. And I wants that when I click to tree node the value of tree node is added to...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.