使用javascript与更新面板 [英] using javascript with update panel

查看:89
本文介绍了使用javascript与更新面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





这是我的代码



< form runat =server> ;

< asp:UpdatePanel ID =UpdatePanel1runat =server>

< contenttemplate>

< asp: DropDownList ID =DropDownList1runat =serverAutoPostBack =TrueOnSelectedIndexChanged =DropDownList1_SelectedIndexChanged>

< asp:ListItem> - Selectione -

< asp:ListItem> Qualitas

< asp:ListItem> ABHS









< asp:UpdatePanel ID =UpdatePanel3runat =server>

< contenttemplate>

< ; div id =mapcanvarunat =server>

< asp:Literal ID =Literal1runat =server>







< / form>







this is my code

<form runat="server">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>--Selectione--
<asp:ListItem>Qualitas
<asp:ListItem>ABHS




<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<contenttemplate>
<div id="mapcanva" runat="server">
<asp:Literal ID="Literal1" runat="server">



</form>


<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
   <script>

       function initialize() {
           var myLatlng = new google.maps.LatLng(33.596854, -7.604025);
           var mapOptions = {
               zoom: 16,
               center: myLatlng
           };

           var map = new google.maps.Map(document.getElementById('mapcanva'), mapOptions);

           var contentString = 'Qualitas Environmental Solutions';

           var infowindow = new google.maps.InfoWindow({
               content: contentString
           });

           var marker = new google.maps.Marker({
               position: myLatlng,
               map: map,
               title: 'Qualitas'
           });
           google.maps.event.addListener(marker, 'click', function () {
               infowindow.open(map, marker);
           });
       }

       google.maps.event.addDomListener(window, 'load', initialize);

   </script>







protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
       {
           if (DropDownList1.Text=="ABHS")
           {
               mapcanva.Visible = false;


           }
           else if (DropDownList1.Text == "Qualitas")
           {
               mapcanva.Visible = true;

           }
       }









当我选择项目ABHS时div设置可见为false但是当我选择Qualitas时div设置为false但是地图不是aprea我不知道为什么plz帮助我





when i selected item "ABHS" the div set visible to false but when i selecte "Qualitas" the div set visible to falsebut the map don't aprea i dont know why plz help me

推荐答案

使用 SelectedValue 属性:



Use the SelectedValue property:

if (DropDownList1.SelectedValue == "ABHS")
{
    mapcanva.Style.Add(HtmlTextWriterStyle.Visibility, "hidden");
}
else if (DropDownList1.SelectedValue == "Qualitas")
{
    mapcanva.Style.Add(HtmlTextWriterStyle.Visibility, "visible");
}


这篇关于使用javascript与更新面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆