none
Error on Load Map on V7 RRS feed

  • Question

  • Hi,

    Not sure what i am doing wrong here. This worked earlier

    Here is my code:
    I am getting this error not sure where i am going wrong.

     

    Server Error in '/' Application.
    Compilation Error
    Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

    Compiler Error Message: BC30456: 'GetMap' is not a member of 'ASP.frm_loadmap_aspx'.

    Source Error:

    Line 19: </head>
    Line 20: <body>
    Line 21:     <form id="form1" runat="server" onload="GetMap();">
    Line 22:     <div>
    Line 23:     </div>

     

    Here is my markup:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>
      <script type="text/javascript">
      function GetMap() {
          var map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),
                  { credentials: "My Bing Key was here",
                    center: new Microsoft.Maps.Location(45.5, -122.5),
                    mapTypeId: Microsoft.Maps.MapTypeId.road,
                    zoom: 7 });
                  }
      </script>
    
    </head>
    <body>
      <form id="form1" runat="server" onload="GetMap();">
      <div>
      </div>
      <asp:Button ID="Button1" runat="server" Text="Click Me" />
      <br />
      <div id='mapDiv' style="position: relative; width: 400px; height: 400px;">
      </div>
      </form>
    </body>
    </html>
    
    • Moved by Ricky_Brundritt Friday, March 9, 2012 3:30 PM (From:Bing Maps: Map Control and Web services Development)
    Thursday, February 24, 2011 5:17 AM

Answers

  • Hi Richard,

    That worked.

    What should i do it if i have to show the map in a button click event?

    Should i use html buttons instead of the asp server buttons?

    The following does not work

     

    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="GetMap();"/>

    This works:

    <

     

    button id="htm_Button" onclick="createMap();"></button>

    Thanks

    Thursday, February 24, 2011 4:32 PM

All replies

  • I'm wondering if maybe because the GetMap call is in the form that has runat="server" if it is trying to call GepMap in code behind rather than in JavaScript. Try moving the onload method to the body tag:

    <body onload="GetMap()">

    If that does not work try this:

     

    <body onload="javascript:GetMap()">


    Windows Live Developer MVP - http://rbrundritt.spaces.live.com | http://inknowledge.co.uk
    Thursday, February 24, 2011 1:38 PM
  • Hi Richard,

    That worked.

    What should i do it if i have to show the map in a button click event?

    Should i use html buttons instead of the asp server buttons?

    The following does not work

     

    <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="GetMap();"/>

    This works:

    <

     

    button id="htm_Button" onclick="createMap();"></button>

    Thanks

    Thursday, February 24, 2011 4:32 PM