2

Having a strange issue with trying to save the scroll position of a Panel that has an imagemap inside of it. We have implemented a scroll position save along with hidden fields that works great in debug mode but does not work when deployed to the server. The scrollleft always resets to 0. I have even captured the fact in edge debug mode that while the hidden field value might be 1768 the scrollleft still maintains its value of 0 AFTER the execution of the below???

Example:

function restore_scroll(control_id) {
    panel = document.getElementById(control_id);
    savex = document.getElementById("savex");
    savey = document.getElementById("savey");

    if (panel != null && panel.hidden == false && savex != null && savey != null) {
        panel.scrollLeft = Number(savex.value);
        panel.scrollTop = Number(savey.value);
    }
}

In debug, savex.value = "1768" and after line execution panel.scrollLeft would still equal 0??? NOTE: I tried converting from string to num but noted this makes no difference, just have not changed back.

And again the confusing part is that it all works fine when debugging???

Page code:

<asp:Panel ID="mappanel" runat="server" ScrollBars="Auto" 
    Width="1200px" Height="650px" ClientIDMode="Static" 
    onscroll="save_scroll('mappanel');">
    <table>
        <tr>
            <td id="facilitymaptd" clientidmode="Static" runat="server"
                onclick="point_it(event);">
                <asp:ImageMap ID="facilitymap" ClientIDMode="Static" 
                    runat="server" ImageAlign="Left" 
                    onclick="ImageMap1_Click" HotSpotMode="PostBack">
                </asp:ImageMap>
            </td>
        </tr>
        <!--
        <tr>
            <td>
                <canvas id="mapcan" runat="server">
                </canvas>
            </td>
        </tr>
        -->
    </table>
</asp:Panel>

I have done some more testing and have found that this looks like a timing issue. I am reloading the imagemap based on a search and if I keep executing this search then sometimes it does retain the scroll position and sometimes it does not???

I say this is timing because when running in debug on my dev machine the loading of the image map is technically local on the dev machine where this does not happen as much. Happens consistently on the deployed server which postbacks are probably a little longer. Does this sound possible?

Thanks in advance

Marshall

BitWiseByteDumb
  • 159
  • 1
  • 12

1 Answers1

0

Well ... I have a fix but not sure why it fixed the issue!?!? The problem's source was the fact that we were changing the image map's url at each postback (Image would change based on hotspot click which certainly others have done?). This reloading of the image really screwed up the restore scroll javascript which was being executed on the window load. We realized the image loading was doing this when implemented a test that did not change the image which fixed the scroll issue so we finally (just by chance) relocated the restore_scroll function to the image map's onload attribute! BAM! Fixed for debug mode and deployment!

My question still might be: Why would this not work at the window load?

Anyway ... thanks for looking everybody!

Marshall

BitWiseByteDumb
  • 159
  • 1
  • 12