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

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

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>
      <td align="right">
          <img src="url('shopping_basket.jpg')" alt="Shopping Basket">
      </td>
    </tr>
    <tr>
      <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:Datagrid>
      </td>
    </tr>  
    <tr>
        <td>
            <asp:button ID="checkoutButton" visible="false" runat="server" text="Checkout"/>
        </td>
    </tr>
</table>

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,
matt.
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

src="shopping_basket.jpg"

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

ASKER

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,

<httpHandlers>
   <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"/>
</httpHandlers>

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

ASKER

i have also now tried the following for the httphandlers;

<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" />
</httpHandlers>

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

ASKER

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

ASKER

hi,

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

-images
-main
-App_Themes
--theme
---myCss.css
--left_side_frame
---web controls
----.ascx
--right_side_frame
...etc

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

ie..

background-image:image/shopping.gif;

to add i have also tried

background-image:~/images/shopping.gif;

and

background-image:url(/images/shopping.gif);

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

ASKER

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

ASKER

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

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