A
Adam Sandler
Hello,
I'm able to reproduce my problem but I haven't been able to figure out
why it is happening. MS does have an article about such behavior in
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q320731 but the
workaround prescribed in the KB isn't particularly helpful.
The project I'm working on serves up a custom jpg image on the client
side at runtime (think MapQuest or Google Maps). We use a COTS product
here to handle the image creation. You'll see the references to the
COTS in the code below through use of the "aims" namespace. As you
will also see, there's no rocket science to the code I've posted.
I'm using some code which was given to me. I've pasted it below in as
a lightweight version. To support some custom functionality (zooming
in and out and identifying objects on the map via a mouseclick among
other things), this code creates the jpg on the server side, places the
path to the jpg in a hidden field, and then on the client side the
hidden field value is set to an html img src.
The problem is the browser's progress bar always keeps increasing and
never stops. Everything else appears to be working normally and the
user can mess around with the page. But the cursor always stays as the
hourglass and pointer combo and the browser's progress bar never
stops incrementing (albeit very slowly).
Eventually, as the page runs for an extended period of time, the
browser throws a stack overflow and the whole thing starts hindering
the performance of the host machine. I did some debugging and noticed
that the codebehind Page_Load event handler keeps getting called
repeatedly. Thinking this was because of the time it takes for the
image to be displayed versus rending the rest of the page, the whole
thing thinks the Page_Load event never completes... kind like an
infinite loop. To get around that I tried wrapping the code in the
Page_Load event handler in an If Not Page.IsPostBack... but that didn't
help either.
I'm now suspecting the problem could be due to the img onload event
handler clashing with the code behind Page_Load event handler. But
nothing too terribly complicated is going on there... I'm just going
out and assigning the src property to the hidden field's value
property.
Suggestions are greatly appreciated.
Thanks!
1. HTML:
<body>
<form id="form1" runat="server">
<div>
<img id="mapImage" src="Images/null.gif" onload="getImage();"/>
<br />
<asp:HiddenField ID="mapImageSrc_hidden" runat="server" />
</div>
</form>
</body>
2. Server-side Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim resultRefresh, urlImage
Dim mConnector As New aims.ArcIMSConnector
mMap = Server.CreateObject("aims.Map")
mConnector = Server.CreateObject("aims.ArcIMSConnector")
mConnector.ServerName = "csfdcrw"
mConnector.ServerPort = 5300
resultInit = mMap.InitMap(mConnector, "Internal")
resultRefresh = mMap.Refresh()
urlImage = mMap.GetImageAsUrl()
Me.mapImageSrc_hidden.Value = urlImage
End Sub
3. Client-side Code:
function getImage()
{
var objHiddenImage = document.getElementById("mapImageSrc_hidden");
var objMapImage = document.getElementById("mapImage");
objMapImage.src = objHiddenImage.value
}
I'm able to reproduce my problem but I haven't been able to figure out
why it is happening. MS does have an article about such behavior in
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q320731 but the
workaround prescribed in the KB isn't particularly helpful.
The project I'm working on serves up a custom jpg image on the client
side at runtime (think MapQuest or Google Maps). We use a COTS product
here to handle the image creation. You'll see the references to the
COTS in the code below through use of the "aims" namespace. As you
will also see, there's no rocket science to the code I've posted.
I'm using some code which was given to me. I've pasted it below in as
a lightweight version. To support some custom functionality (zooming
in and out and identifying objects on the map via a mouseclick among
other things), this code creates the jpg on the server side, places the
path to the jpg in a hidden field, and then on the client side the
hidden field value is set to an html img src.
The problem is the browser's progress bar always keeps increasing and
never stops. Everything else appears to be working normally and the
user can mess around with the page. But the cursor always stays as the
hourglass and pointer combo and the browser's progress bar never
stops incrementing (albeit very slowly).
Eventually, as the page runs for an extended period of time, the
browser throws a stack overflow and the whole thing starts hindering
the performance of the host machine. I did some debugging and noticed
that the codebehind Page_Load event handler keeps getting called
repeatedly. Thinking this was because of the time it takes for the
image to be displayed versus rending the rest of the page, the whole
thing thinks the Page_Load event never completes... kind like an
infinite loop. To get around that I tried wrapping the code in the
Page_Load event handler in an If Not Page.IsPostBack... but that didn't
help either.
I'm now suspecting the problem could be due to the img onload event
handler clashing with the code behind Page_Load event handler. But
nothing too terribly complicated is going on there... I'm just going
out and assigning the src property to the hidden field's value
property.
Suggestions are greatly appreciated.
Thanks!
1. HTML:
<body>
<form id="form1" runat="server">
<div>
<img id="mapImage" src="Images/null.gif" onload="getImage();"/>
<br />
<asp:HiddenField ID="mapImageSrc_hidden" runat="server" />
</div>
</form>
</body>
2. Server-side Code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim resultRefresh, urlImage
Dim mConnector As New aims.ArcIMSConnector
mMap = Server.CreateObject("aims.Map")
mConnector = Server.CreateObject("aims.ArcIMSConnector")
mConnector.ServerName = "csfdcrw"
mConnector.ServerPort = 5300
resultInit = mMap.InitMap(mConnector, "Internal")
resultRefresh = mMap.Refresh()
urlImage = mMap.GetImageAsUrl()
Me.mapImageSrc_hidden.Value = urlImage
End Sub
3. Client-side Code:
function getImage()
{
var objHiddenImage = document.getElementById("mapImageSrc_hidden");
var objMapImage = document.getElementById("mapImage");
objMapImage.src = objHiddenImage.value
}