G0ggy
asked on
Dynamic image not appearing in online assessment
Hi all,
The attached code is a segment from my online assessment web page. This code used to work, but as of today it has stopped. I do not know when it last worked. All the other assessment question work fine, but if the question is an image, the image does not show, I only get the image placeholder. I have tested this in Firefox and IE and the result is the same, the 'test' string variable is where I have tested to see if the path is correct, which it is and the image exists. I just cannot see why it has stopped working.
Can you think of anything else that could be stopping ut showing?
Cheers.
The attached code is a segment from my online assessment web page. This code used to work, but as of today it has stopped. I do not know when it last worked. All the other assessment question work fine, but if the question is an image, the image does not show, I only get the image placeholder. I have tested this in Firefox and IE and the result is the same, the 'test' string variable is where I have tested to see if the path is correct, which it is and the image exists. I just cannot see why it has stopped working.
Can you think of anything else that could be stopping ut showing?
Cheers.
If row("questiontype") = 37 Then
Dim img As Image = New Image()
Dim test As String = Server.MapPath("~/secure/images/aqimages/" & row("questionImageFilename").ToString)
img.ImageUrl = Server.MapPath("~/secure/images/aqimages/" & row("questionImageFilename").ToString)
img.Width = 700
img.Height = 300
img.Visible = True
pnlAssessment.Controls.Add(img)
End If
ASKER
It hits the function and the value of 'test' in the code is the correct path to the image (tested by copying it into IE, the image displays correctly)
Have you tried removing the "~" from the Server.MapPath? I think that is redundant.
ASKER
That doesn't make any difference. It's wierd, if you look at this section of a screenshot, you can see the image place-holder, which is not broken (which would indicate that the image could not be found) yet it does not appear...
Untitled-1.gif
Untitled-1.gif
I doubt it would load the page if it wasn't, but are you SURE you are adding a
System.Web.UI.WebControls. Image
and not a
System.Drawing.Image ?
Does it work if you use an HtmlImage control?
System.Web.UI.WebControls.
and not a
System.Drawing.Image ?
Does it work if you use an HtmlImage control?
ASKER
Same results as before, tried both of your suggestions...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The image is stored locally yes...
locally on the users computer, right?
Regardless, this isn't an ideal solution, and browsers are cracking down on any access a web page can have to the users hard drive. If it suddenly stopped working, I would start looking into security settings in the browser, because your code is probably fine.
Regardless, this isn't an ideal solution, and browsers are cracking down on any access a web page can have to the users hard drive. If it suddenly stopped working, I would start looking into security settings in the browser, because your code is probably fine.
ASKER
No locally on the web server. If I spec the situation for you. The instructors can create questions, which can be multiple choice, text or images. If it is an image question they upload an image file to the web server. I need to reference this image file from the question in the database. The name of the image is stored with the question.
Your previous comment made me suspicious about the paths, so I changed the URL to a fully qualified http address to the localhost which worked. Is this the ideal solution?
Your previous comment made me suspicious about the paths, so I changed the URL to a fully qualified http address to the localhost which worked. Is this the ideal solution?
Certainly yes. You really shouldn't EVER have to use a local path within a "web"page. If the resource isn't being served over HTTP, then there isn't much of a guarantee your user is ever going to see them.
ASKER
Then the points are yours my good man.
ASKER
Cheers.
If it worked previously with no issues then you may not be passing the right value in or the data in your DB may not be accurate.