Click here to Skip to main content

Shiridish asked:

Open original thread
I have a Google Map on which I display markers by fetching the latlng's from a database on a Button Click. To avoid postback I put this button in an update panel.
<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" 
            style="z-index: 1; left: 778px; top: 270px; position: absolute; height: 25px" Text="Button" />
        </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>

Button_Click:
protected void Button1_Click(object sender, EventArgs e)
    {
        //Some code to fetch latlng's from database
        //Passing the final needed value to a <asp:HiddenField> at this point
        ScriptManager.RegisterClientScriptBlock(this, typeof(Button), "currentloc", "showcurrent()", true);
    }
Javascript in aspx:
function showcurrent()
    {
     var rec_loc= document.getElementById('<%=currentloc.ClientID %>').value;
     var splitloc=[];
     splitloc= rec_loc.split(',');
     var clat=parseFloat(splitloc[0]);
     var clng=parseFloat(splitloc[1]);
     var cpos= new google.maps.LatLng(clat,clng);
     var cmarker= new google.maps.Marker({icon:'http://www.googlemapsmarkers.com/v1/A/0099FF/', position:cpos,map:map});  
     map.setCenter(cmarker.getPosition());
    }
In body onload I initialize and load the map and its fine. But when I click the button, I end up with a blue screen in the map(the map controls like zoom, etc are still there though). Where am I doing wrong? Please help.
Tags: ASP.NET, Ajax, Google-Maps, updatepanel, postback

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web01 | 2.8.150302.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100