如何在ViewState中保存div及其内容?

时间:2013-05-22 13:43:09

标签: javascript vb.net html panel autopostback

我有一个div,其内容将通过javascript填充并返回一个图像,但我的问题是:我有4个下拉列表,AutoPostBack = true,它导致我的div的内容消失... 如何将图像保存为始终显示?我读过有关ViewState的内容,但无法做任何事情......

这是我的代码:

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

达网络

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

我也尝试从div更改为面板,但没有任何改变

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

1 个答案:

答案 0 :(得分:0)

没关系,就去吧!我唯一做的就是检查我的页面是否回发,然后调用我的javascript!