A
Adam Sandler
Hello,
Having an issue with JavaScript in 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 checking for
top.PostBackDone. Additionally I tried putting the call in
window.onload...
<head>
<script type="text/javascript">
function getMap()
{
if (arguments.callee.done) return;
arguments.callee.done = true;
var objHiddenImage =
document.getElementById("mapImageSrc_hidden");
var objMapImage = document.getElementById("mapImage");
objMapImage.src = objHiddenImage.value;
}
window.onload = getMap;
</script>
</head>
On objMapImage.src = objHiddenImage.value, I get the "null is null or
not an object" error and the image doesn't show... even though
debugging clearly shows a valid path string in objHiddenImage.value!!!
Any suggestions are greatly appreciated.
Thanks!
Having an issue with JavaScript in 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 checking for
top.PostBackDone. Additionally I tried putting the call in
window.onload...
<head>
<script type="text/javascript">
function getMap()
{
if (arguments.callee.done) return;
arguments.callee.done = true;
var objHiddenImage =
document.getElementById("mapImageSrc_hidden");
var objMapImage = document.getElementById("mapImage");
objMapImage.src = objHiddenImage.value;
}
window.onload = getMap;
</script>
</head>
On objMapImage.src = objHiddenImage.value, I get the "null is null or
not an object" error and the image doesn't show... even though
debugging clearly shows a valid path string in objHiddenImage.value!!!
Any suggestions are greatly appreciated.
Thanks!