Displaying images

S

Shelly

I have two problems with what I am working on and would appreciate
suggestions.

Problem 1: The images are not displaying. I see that small box placeholder.
Problem 2: The hyperlink is doing nothing.

Here is the section of code for the display:
<ItemTemplate>
<asp:Image Id="Image1" runat="server" ImageUrl='<?#
Container.DataItem("TheFile") %>' />
<br>
<asp:Hyperlink ID="Hyperlink1" runat="server" Target="_blank"
NavigateUrl='<%# Container.DataItem("TheFile") %>'>
<%# Container.DataItem("TheName") %></asp:Hyperlink>
</ItemTemplate>


In the vb code-behind, the relevent code is:
dt = New DataTable
dt.Columns.Add(New DataColumn("TheFile", GetType(String)))
dt.Columns.Add(New DataColumn("TheName", GetType(String)))

For Each File in files
Dim name as String = getfiletitle(File)
dr = dt.NewRow()
dr(0) = File
dr(1) = name
dt.Rows.Add(dr)
Next

CreateDataSource = New DataView(dt)


Now when I look in the debugger, the value for File is correct and is
something like C:\the_full_path\the_file.jpg and the value for name is also
correct as the_file.jpg. The value that appears on the screen for the
hyperlink is correct and is the value of name. Putting the mouse over the
hyperling yields something like file:///c:/the_full_path/the_file.jpg, but
clicking it does nothing. Getting the properties of the block placeholder
for the picture just gives a "general" tab and the value is just the name of
the file. It doesn't display.

Any help would be appreciated.
 
S

Shelly

A little more info on the hyperlink problem. I added a third item to the
ItemTemplate. It is

<br /><a href="C:/the_complete_file_path/JonFamily.jpg">Jon Family</a>

Of course, it shows up as the third thing for each and is the same for all
three image files that are in my directory. When I click on it, nothing
happens. When I cut and paste that specification into the browser address
line, the file displays.

-- Is there some setting in the DataList that needs changing?
-- Should I be using other than ItemTemplate?
-- What about the display problem I am still having?

I am blocked and need some help.

Shelly
 
S

Shelly

More weirdness!
Just to see what would happen, I put <img id="foo"
src="C:\the_full_path\JonFamily.jpg" />. It didn't display either, and this
was right below my Content statement. If I cut and paste that URL, it
displays.

Suggestions? Whatever it is, it will probably solve both problems when I
find out.

Shelly


Shelly said:
A little more info on the hyperlink problem. I added a third item to the
ItemTemplate. It is

<br /><a href="C:/the_complete_file_path/JonFamily.jpg">Jon Family</a>

Of course, it shows up as the third thing for each and is the same for all
three image files that are in my directory. When I click on it, nothing
happens. When I cut and paste that specification into the browser address
line, the file displays.

-- Is there some setting in the DataList that needs changing?
-- Should I be using other than ItemTemplate?
-- What about the display problem I am still having?

I am blocked and need some help.

Shelly
 
S

Shelly

I take that back! The relative path did the trick. Thank you very much.
The absolute path may also work, but it didn't for me here as I had to use
file://___stuff___. (I am using a localhost server).

Shelly

Shelly said:
Harshal Pachpande said:
The image path should not be absolute. Try relative path or full path
e.g. http://server/appname/images/imagename.jpg
Secondly the data bound expression seems little strange
<?# Container.DataItem("TheFile") %>

It made no difference
shouldn't this be like
<%# Container.DataItem("TheFile") %>

typo. It was as you have it.
 
M

Mick Walker

Shelly said:
I take that back! The relative path did the trick. Thank you very much.
The absolute path may also work, but it didn't for me here as I had to use
file://___stuff___. (I am using a localhost server).

Shelly

Shelly said:
It made no difference

typo. It was as you have it.
Look into Server.MapPath()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,037
Messages
2,570,371
Members
47,013
Latest member
JewellChes

Latest Threads

Top