Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
hi,

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>


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


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


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

           }
       }




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
Posted

1 solution

Use the SelectedValue property:

C#
if (DropDownList1.SelectedValue == "ABHS")
{
    mapcanva.Style.Add(HtmlTextWriterStyle.Visibility, "hidden");
}
else if (DropDownList1.SelectedValue == "Qualitas")
{
    mapcanva.Style.Add(HtmlTextWriterStyle.Visibility, "visible");
}
 
Share this answer
 
v2
Comments
Member 11573837 27-Apr-15 4:20am    
hi Gideon van Dyk,
thank you for answering me, i update my code but the div wich have map don't apear i think same thing whit UpdatePanel and javascript
i'm waiting for you :D
Gideon van Dyk 27-Apr-15 19:07pm    
You might want to add the style of setting style visibility. Updated the solutions.
Member 11573837 28-Apr-15 4:20am    
hi
this's my code

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

</div>



for hidden and visible the div it works but the map don't apear i have add
border: 2px solid #326195; to my div to check if it work but like i say the (map google mape ) don't apear
Gideon van Dyk 28-Apr-15 18:30pm    
I think it's more a case of the JavaScript, as the update panel will not execute the "window.load" event. You will need to add a direct script call to the mapping JavaScript function.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900