473,802 Members | 2,374 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1439
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******** ********@TK2MSF TNGP05.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
4396
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 from a list of brochure categories, then once they press the submit button they will be taken to a different page www.tripakltd.com/library.asp The problem i am having, is that when I tell the detail page about the variable from the master page as...
1
1284
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 uses the master.
7
1961
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 I've created StartDate and EndDate properties, which are basically wrappers around the SelectedDates property from the Calendar control. When I select another date in the Calendar, the page updates normally, but when Page_Load for the content page...
0
1070
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 opened in design view. However, if the master page is not open in design view, then webforms opened in design view don't display correctly at all. Here are the specifics: My master page has the following lines of html: <head runat="server"...
1
4031
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 wrong. I have simplified the problem with the following example: Using asp.net 2.0, I have a Master page template used on default.aspx. >From within the Content tags on that page I placed a Datalist. It is iterating a User control "Inner" with...
3
2365
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 different pages. All that's working fine... The problem I'm having is that the images don't show onscreen the first time the "first page" of results shows up. When I click the "search again" button, and have more than the original results page to...
2
1384
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) (MasterControl.ascx). When placed on the master page this appears as <uc1:MasterControl ID="MasterControl1" runat="server" />. The MasterControl's Page_Init() event will contain some code to examine the
5
2106
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 master page, I cannot create another form tag with "runat=server" attribute as ASP.NET does not allow two FORM Server tag in the same page. The problem now is in the contentPlaceHolder, how to control the "submit"
5
2284
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 never displayed. Not sure whats wrong. Below is my code. Any help would be appreciated. VS2008. MasterPage1.Master: <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage1.master.cs"
1
4889
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 Session and data from database regarding to that tree node value. Will fetch the records and load that on content page on Content Page Load event. But the problem is that When click tree node the fallowing events occurs ...
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10535
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10303
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10282
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.