471,592 Members | 1,065 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,592 software developers and data experts.

problem with providing an image src property


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 =
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.

Jan 23 '07 #1
0 1058

This discussion thread is closed

Replies have been disabled for this discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.