Question

I have a div, which contents will be filled via javascript and return an image, but my problemn is: i have 4 dropdownlist with AutoPostBack=true and it causes the content of my div to disappear... How do I save the image to always appear? I've read about ViewState, but couldn't do anything...

Here is my code:

<script language="javascript" type="text/javascript">

    function fonte(lat, lon) {
        var src = "http://maps.google.com/maps/api/staticmap?center=" + lat + "," + lon + "&zoom=15&size=540x280&ma‌​ptype=roadmap&markers=color:red|" + lat + "," + lon + "&sensor=false";

        testando(src, 540, 280, "Mapa");
    }
    function endereco(endereco) {
        var fonte = endereco.split(' ').join('+');
        var src = "http://maps.google.com/maps/api/staticmap?center=" + fonte + "&zoom=16&size=540x280&ma‌​ptype=roadmap&markers=color:red|" + fonte + "&sensor=false";

        testando(src, 540, 280, "Mapa");
    }
    function testando(src, width, height, alt) {
        var img = document.createElement("img");
        img.src = src;
        img.width = width;
        img.height = height;
        img.alt = alt;
        document.getElementById("mapa").innerHTML=img;
        }
</script>

.net

<div class="formLine" id="mapa1"  style="width:100%; height:100%" align="center"  runat="server">

and I also tried to change from div to panel, but nothing changed

       <asp:Panel ID="mapa" runat="server" style="width:100%; height:100%" align="center" Visible="true">
                </asp:Panel>
Was it helpful?

Solution

Nevermind, just go it! The only thing I did was check if my page is post back, then call my javascript!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top