Results 1 to 6 of 6

Thread: [Resolved] [2008] ImageButton not displaying Image

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    22

    [Resolved] [2008] ImageButton not displaying Image

    Hello,

    I have an ImageButton, which looks fine in the design mode, but when I run the application the image appears as a red 'x'.


    <asp:ImageButton ID="imgExport" runat="server"
    ImageUrl="~/App_Data/excel_icon.jpg" />

    I think that the code looks OK and the permissions of the App_Data folder look fine, but I am at a loss of what to check next.

    I'm sure its a newbie error, but I have potterd around for a while without finding the solution, I would welcome any help.
    Last edited by Ping_Chow_Chi; Feb 20th, 2009 at 04:52 AM.

  2. #2
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602

    Re: [2008] ImageButton not displaying Image

    Hi!

    Have you checked the image url at runtime to see where it points? Then try and display this image by typing that url in the browser.

    Also, try to create an "Images" folder in the webproject root and put your pictures there. There is no particular reason to put the images in App_Data. A better place would be the resx files if you want more control.

    /Henrik

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    22

    Re: [2008] ImageButton not displaying Image

    hi, thanks for the reply

    I have put the pic in a pictures folder and get the following when look at the ImageURL at run time

    ~/App_Data/pictures/excel_icon.jpg



    When I try to access it (I assume that this would be the correct path) using


    http://localhost:63546/WebSite2/App_...excel_icon.jpg


    I get



    Server Error in '/WebSite2' Application.
    --------------------------------------------------------------------------------

    HTTP Error 403 - Forbidden.

    --------------------------------------------------------------------------------
    Version Information: ASP.NET Development Server 9.0.0.0
    Last edited by Ping_Chow_Chi; Feb 19th, 2009 at 05:38 AM.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2008] ImageButton not displaying Image

    Never place images in the App_Data folder. It is a special folder meant only for database related files. You need to move your images.

    Also, note that images are not actually data, so logically they shouldn't be in the App_Data folder anyways.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Oct 2006
    Posts
    22

    Re: [2008] ImageButton not displaying Image

    Well, I moved it to a seperate folder outside of the app_data folder and .... hey presto it worked!

    So, thankyou


  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [Resolved] [2008] ImageButton not displaying Image

    Nicely done.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width