如何在ViewState中保存div及其副本?(How do I save a div and its contets in ViewState?)

编程入门 行业动态 更新时间:2024-10-25 02:30:10
如何在ViewState中保存div及其副本?(How do I save a div and its contets in ViewState?)

我有一个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改为panel,但没有改变

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

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>

最满意答案

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

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

更多推荐

本文发布于:2023-07-25 10:40:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1260007.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:副本   如何在   ViewState   div   save

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!