Hi
I am coding on VB2005 on Windows XP service pack 2
I am having a problem with adding images to my web site.
It work perfectly in development but they are missing in runtime.
I feel that I have tried everything but still cannot get the images to appear on the page at runtime.
I have placed the images in numerous places.
They are in the application folder.ie. logo.gif
They are also in a folder called /Images/logo.gif and also in /bin/Images/logo.gif or even
I have tried everyway to refer to them in the code but the only one that works in to have
them refered by the full path
http://localhost/projectname/logo.gif or using c//wwwroot/inetpub/.......
But obviously this wont allow the site to be easly deployable.
Also I know that VB 2005 includes image files in its security
So I have tried setting
<authentication mode="None"/> and <authentication mode="Windows"/> but this doesn't work.
Neither does :
<location path="logo.gif">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
The image problem was thought to be minor and was left until alot of work had been completed on the project.
The project is now ready to go live but I can't deply it looking a mess with no nice images.
If you are using the Image server control, or placing the images on your page through your code behind, you shoudl reference the images using the "~/" syntax to refer to the application root. So if the image is in the root of your application's directory
structure you could reference it through "~/logo.gif". If you had it stored in a folder called "images" you would use "~/images/logo.gif", etc.
the html looks good, so it has to be the ImageUrl field is not set correctly.
have you tried viewing the properties of the image, clicking the "..." box in the ImageUrl field and selecting the image from the list? this way you don't have to type in anything, VS will do it for you. i expected the url to start with "~/"
when you say the images are not showing, do you mean all of the images or just the logo.gif?
does the page show an image box with an "X" in it or is it just not showing anything?
<asp:Image > tags use the ~ mark because they are run on the server.
<img src> tags run on the browser unless you add
<img src="location" runat=server
so if you have <asp:Image> tags use the "~/" as root - other wise if you have <img> tags, add the "runat" attribute and then the "~/" will work as root
thanks for the reply but the image path is not the problem as this works with Visual Studio and also works when the project is run on a development server.
This only occurs at runtime when running within VS.
chime
Member
74 Points
14 Posts
image not showing on web page at runtime.
Aug 11, 2006 12:49 PM|LINK
Hi
I am coding on VB2005 on Windows XP service pack 2
I am having a problem with adding images to my web site.
It work perfectly in development but they are missing in runtime.
I feel that I have tried everything but still cannot get the images to appear on the page at runtime.
I have placed the images in numerous places.
They are in the application folder.ie. logo.gif
They are also in a folder called /Images/logo.gif and also in /bin/Images/logo.gif or even
I have tried everyway to refer to them in the code but the only one that works in to have
them refered by the full path http://localhost/projectname/logo.gif or using c//wwwroot/inetpub/.......
But obviously this wont allow the site to be easly deployable.
Also I know that VB 2005 includes image files in its security
So I have tried setting
<authentication mode="None"/> and <authentication mode="Windows"/> but this doesn't work.
Neither does :
<location path="logo.gif">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
The image problem was thought to be minor and was left until alot of work had been completed on the project.
The project is now ready to go live but I can't deply it looking a mess with no nice images.
avanslaars
Member
729 Points
139 Posts
Re: image not showing on web page at runtime.
Aug 11, 2006 01:38 PM|LINK
If you are using the Image server control, or placing the images on your page through your code behind, you shoudl reference the images using the "~/" syntax to refer to the application root. So if the image is in the root of your application's directory structure you could reference it through "~/logo.gif". If you had it stored in a folder called "images" you would use "~/images/logo.gif", etc.
Hope this helps.
vanslaars.net
chime
Member
74 Points
14 Posts
Re: image not showing on web page at runtime.
Aug 11, 2006 02:08 PM|LINK
Hi Andrew
Thanks for replying.
I have tried ~/logo.gif ~/Images/logo.gif and even ~/bin/Images/logo.gif as these are the three places I have the images stored.
I have also tries just /logo.gif and logo.gif
I am really running out of ideas and under pressure to get the application into production.
I would leave it as
http://localhost/projectname/logo.gif but I can't as it may be deployed under different virtual directories
It could be a setting somewhere but I just can't work out how to fix it.
Thanks
cats
regexp
Member
60 Points
15 Posts
Re: image not showing on web page at runtime.
Aug 11, 2006 02:30 PM|LINK
can you post your <asp:Image... /> tag from the html?
shominy
Member
123 Points
43 Posts
Re: image not showing on web page at runtime.
Aug 11, 2006 02:32 PM|LINK
(where d:\inetpub\wwwroot\water\maptechs\welllogs\appnew\images\tif.gif)
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="../images/tif.gif" />
Or
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="/projectname/logo.gif" />
Hope this helps.
chime
Member
74 Points
14 Posts
Re: image not showing on web page at runtime.
Aug 11, 2006 02:57 PM|LINK
Thanks for all the replys
Here is the page that doesn't work
It is a master page from a project in which the images used to show before and after converting from VB2003 to VB 2005
When I changed to be a master page the images stopped showing.
But just to add to the confustion here is a page that does work but in a different solution/project
Again converted from VB 2003 to VB 2005 and with a master page added but it does work in this case
<%
@ Master Language="VB" AutoEventWireup="false" CodeBehind="FundReg.master.vb" Inherits="FundRegistry.FundReg" %><!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><
html xmlns="http://www.w3.org/1999/xhtml" ><
head runat="server"> <title>Fund Registry</title> <meta content="False" name="vs_showGrid"/> <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"/> <meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE"/> <meta content="JavaScript" name="vs_defaultClientScript"/> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"/> <style type="text/css">.DataGridFixedHeader { POSITION: relative; ; TOP: expression(this.offsetParent.scrollTop); BACKGROUND-COLOR: #990033 } </style><
script language="javascript" type="text/javascript"><!--
// -->
</
script></
head><
body> <form id="form1" runat="server"> <table style="WIDTH: 855px; HEIGHT: 767px" cellspacing="0" cellpadding="0" align="center" border="2" > <tbody> <tr> <td valign="top" width="1%" bgColor="#edebea"> <table style="WIDTH: 848px; HEIGHT: 707px; position: absolute; z-index: 100;" cellspacing="0" cellpadding="0" width="848" border="0"> <tbody> <tr> <td style="WIDTH: 549px; HEIGHT: 87px; background-image: url(banBack.gif);" > <table id="Table1" style="WIDTH: 806px; HEIGHT: 96px" cellspacing="0" cellpadding="0" width="806" border="0"> <tr> <td style="WIDTH: 252px; background-image: url(banBack.gif); height: 63px;"> <asp:Image ID="Image1" runat="server" BorderStyle="None" ImageAlign="Left" ImageUrl="~/logo.gif" /></td> <td style="height: 63px"> <div style="DISPLAY: inline; FONT-SIZE: 40px; WIDTH: 468px; HEIGHT: 46px">FUND REGISTRY</div> </td> </tr> </table> </td> </tr> <tr> <td style="WIDTH: 549px; HEIGHT: 24px " background="utilBack.gif" ><img height="24" src="spacer.gif" width="100" border="0"/></td> </tr> <tr> <td style="WIDTH: 549px; HEIGHT: 1px" background="lineBack.gif"><img height="4" src="spacer.gif" width="100" border="0"/></td> </tr> <tr> <td style="WIDTH: 549px; HEIGHT: 14px"><img style="WIDTH: 100px; HEIGHT: 2px" height="2" src="spacer.gif" width="100" border="0"/></td> </tr> <tr> <td style="WIDTH: 549px; HEIGHT: 561px"> <table style="WIDTH: 844px; HEIGHT: 565px" cellspacing="0" cellpadding="0" width="844" border="0"> <tbody> <tr> <td style="WIDTH: 17px; HEIGHT: 559px"></td> <td style="WIDTH: 775px; HEIGHT: 559px" colspan="1" align="left" valign="top"> <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"> </asp:ContentPlaceHolder> <asp:Label ID="lblDevelopedBy" runat="server" Font-Size="Smaller" Height="12px" Style="z-index: 101;left: 22px; position: absolute; top: 729px"
Text="IT Development June 2006" Width="487px"></asp:Label> </td> </tr> </TBODY> </table> </td> </tr> </tbody> </table> <asp:label id="lblSpace" runat="server" ForeColor="Gainsboro">....</asp:label> <asp:label id="lblDevelop" runat="server" Height="26px"></asp:label> </td> </tr> </tbody> </table> </form></
body></
html>regexp
Member
60 Points
15 Posts
Re: image not showing on web page at runtime.
Aug 11, 2006 03:32 PM|LINK
the html looks good, so it has to be the ImageUrl field is not set correctly.
have you tried viewing the properties of the image, clicking the "..." box in the ImageUrl field and selecting the image from the list? this way you don't have to type in anything, VS will do it for you. i expected the url to start with "~/"
when you say the images are not showing, do you mean all of the images or just the logo.gif?
does the page show an image box with an "X" in it or is it just not showing anything?
chime
Member
74 Points
14 Posts
Re: image not showing on web page at runtime.
Aug 11, 2006 04:58 PM|LINK
Hi
I have selected the image using the .. box and it loads up correctly into the page.
None of the images show
(some are just back ground images)
I have deleted all the images and added them in again and they still don't show.
Thanks
cats.
regexp
Member
60 Points
15 Posts
Re: image not showing on web page at runtime.
Aug 17, 2006 04:23 PM|LINK
a quick note about image tags-
<asp:Image > tags use the ~ mark because they are run on the server.
<img src> tags run on the browser unless you add
<img src="location" runat=server
so if you have <asp:Image> tags use the "~/" as root - other wise if you have <img> tags, add the "runat" attribute and then the "~/" will work as root
chime
Member
74 Points
14 Posts
Re: image not showing on web page at runtime.
Aug 22, 2006 12:29 PM|LINK
Hi
thanks for the reply but the image path is not the problem as this works with Visual Studio and also works when the project is run on a development server.
This only occurs at runtime when running within VS.
So its a setting somewhere
thanks