Link to home
Create AccountLog in
Avatar of flynny
flynnyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

images not appearing in ascx file

hi all i have the following ascx file, when i load it into an aspx the image does not appear can anyone tell me why this is so?

i have in my web.config

        <remove verb="*" path="*.jpg,*.jpeg,*.gif,*.png" />
        <add verb="*" path="*.jpg,*.jpeg,*.gif,*.png" type="System.Web.StaticFileHandler" />

and my ascx file

<%@ Control Language="VB" AutoEventWireup="false" CodeFile="side_cart.ascx.vb" Inherits="side_cart" %>

<table border="1" border-color="silver">
    <tr class="ShoppingCart">
        <td align="left">
            Shopping Basket
      <td align="right">
          <img src="url('shopping_basket.jpg')" alt="Shopping Basket">
      <td class="ShoppingCartList" colspan="2">
            <asp:Label ID="emptyCartLabel" runat="server">Your shopping basket is currently empty.</asp:Label>
          <asp:Datagrid ID="cartDataGrid" runat="server">
            <asp:button ID="checkoutButton" visible="false" runat="server" text="Checkout"/>

i have also trie having the file simply as '<filename>' this didnt work, the jpeg is currently in the folder with the ascx file and not the aspx which is  one level above it. I have tried moving this file in with the aspx file and this had no effect either.

any ideas?

many thanks in advance,
Avatar of Jeeva Subburaj
Jeeva Subburaj
Flag of United States of America image

just remove the URL( part from the SRC. this URL( will be used only if you are defining in stylesheets.. just try like this


and keep the image in the same folder.. and try..

and if nothing works, remove those configration settings (HTTPHandler adding Verb) and try it. if that works, then it cud b problem with ur httphandler.
Avatar of flynny


hi vavjeeva,

i have tried the src="shopping_basket.jpg" and this didnt work, i have also tried it without the httphandlers (this was the reason i added them to the web.config) as becasue the images were not appearing i googled to try and find the reason and found i needed these.

to add i have tried the following in my web.config,

   <add verb="*" path="*.jpg" type="ASPNET.StarterKit.Communities.ImageHandler"/>
   <add verb="*" path="*.jpeg" type="ASPNET.StarterKit.Communities.ImageHandler"/>
   <add verb="*" path="*.gif" type="ASPNET.StarterKit.Communities.ImageHandler"/>

and this gives the error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load type 'ASPNET.StarterKit.Communities.ImageHandler'.

Source Error:

Line 5:  
Line 6:        <httpHandlers>
Line 7:          <add verb="*" path="*.jpg" type="ASPNET.StarterKit.Communities.ImageHandler"/>
Line 8:          <add verb="*" path="*.jpeg" type="ASPNET.StarterKit.Communities.ImageHandler"/>
Line 9:          <add verb="*" path="*.gif" type="ASPNET.StarterKit.Communities.ImageHandler"/>

Source File: C:\WebSite1\web.config    Line: 7

coulld i be missing something?
Avatar of flynny


i have also now tried the following for the httphandlers;

<add verb="*" path="*.jpg" type="ASPNET.StarterKit.Communities.ImageHandler, ASPNET.StarterKit.Communities" />
<add verb="*" path="*.jpeg" type="ASPNET.StarterKit.Communities.ImageHandler, ASPNET.StarterKit.Communities" />
<add verb="*" path="*.gif" type="ASPNET.StarterKit.Communities.ImageHandler, ASPNET.StarterKit.Communities" />

again with no luck, am i missing an installed component?
Avatar of flynny


hi they are now appearing in my visual web express 2008 if i right click view in browser however when they are on the web they don't. both the webconfigs are the same any ideas?
Avatar of flynny



i've got it the image to appear however not in the css file. i have the following structure

---web controls

in the .ascx file if i use for a background

<table background="images/shopping.gif" class="cssclass">

the image appears

however if i then remove the background attribute and add it to the 'cssclass' it doesnt appear



to add i have also tried




any ideas?
the image doesn't appear
Avatar of flynny


solved using ~/images/.. fixed the prob ;)
Avatar of flynny


sorry this used used along with url('~/images/etc..') solved the problem
Avatar of Computer101
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account