img not displaying in listview control

mugsey
mugsey used Ask the Experts™
on
I have a listview control populating a set of images and alt tags but only the alt tags are being displayed.

I know that the path to the images and file name is correct but it is not showing.   If I view in chrome I get alt tag (description) and if I view in IE8 I get "no image" symbol and alt tag (description)

The <img src="<%#Eval("FilePath") %> returns the location AND the imageID so this is correct.

The images are located in the c:\images\     directory

<ItemTemplate>
        <div>
            <img src="<%#Eval("FilePath") %>" alt="<%#Eval("Description") %>" />
        </div>
    </ItemTemplate>

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
I think it is because of the local folder (C:\images). If you place it in the web root and give the relative path, it would help I believe.
Try


<ItemTemplate> 
        <div> 
            <img src="File://<%#Eval("FilePath") %>" alt="<%#Eval("Description") %>" /> 
        </div> 
    </ItemTemplate>

Open in new window

Please just note that the above will only render if the files actuall exist in the LOCAL computers location.

If you want this to work remotly you need the path to end up looking something like one of these:

~/images/inage.jpg
../../images/image.jpg
http://vd.domain.com/images/image.jpg

etc....

Author

Commented:
ok thanks I set the path to the virtual directory as oppose to the physical directory in the asp.net app.

Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial