problem with providing an image src property

A

Adam Sandler

Hello,

Having an issue with my ASP.Net page.

I use some COTS, which for all intents and purposes, simply makes a
jpeg file and physically places it in a directory on the web server.

The page load codebehind, makes a connection to the jpeg creation
service and gets the path of the newly created image.

The sample code I'm providing is very simple... no rocket science here.


Here's the code behind:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load

Dim j As New jpegImage ' removed code for COTS & replaced
with psuedocode for posting purposes.
Dim c As New serviceConnector ' removed code for COTS & replaced
with psuedocode for posting purposes.
Dim urlImage

c = Server.CreateObject("Connector") ' removed code for COTS &
replaced with psuedocode for posting purposes.
c.ServerName = "DC1" ' Server's name
c.ServerPort = 5300 ' Server's port

j = Server.CreateObject("Jpeg") ' removed code for COTS &
replaced with psuedocode for posting purposes.
urlImage = j.GetImageAsUrl() ' string with path to newly
created jpeg file on server

Me.mapImageSrc_hidden.Value = urlImage

End Sub

Okay... you'll see that I'm using a hidden field in the page markup.
There's a bunch of reasons for this madness I'll skip for now but I
need the client to load the image... not the server. Here's what
happens next:

<asp:HiddenField ID="mapImageSrc_hidden" runat="server" />
<img id="mapImage" src="Images/null.gif" onload="getImage();" />

And in here's the getImage method:

function getImage()
{
var objHiddenImage =
document.getElementById("mapImageSrc_hidden");
var objMapImage = document.getElementById("mapImage");

objMapImage.src = objHiddenImage.value;
}

The problem is on the last line of the getImage method... when I put
the hidden field's value in the src property of the html image, the
page gets stuck in an infinte loop. It's as if the page never fully
loads, even though image generation is complete on the server, so the
onload=getImage() keeps getting fired over and over again.

Adding a "return" to the function doesn't help... nor does putting the
call in window.onload or checking for top.PostBackDone.

Interestingly enough, when I use an ASP image, I don't have this
dilemma... just when I use a HTML image. But I need to use a HTML
image as there's some client side JavaScript which will manipulate the
image down the road which won't work on an ASP type.

Any suggestions on how to solve the infinite loop I just described are
greatly appreciated.
 

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
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top