map.Overlays.Add(polygon) throws InvalidOperationException

Mar 29, 2012 at 6:49 PM

I'm adding a polygon to an instance of the GoogleMap control and it works fine the first time the page is loaded, but if I refresh the page, I get the following error.  Any ideas how to fix this?

System.InvalidOperationException: Extender controls may not be registered after PreRender.

WebForm1.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="CleanAir.PlotComplaints.WebForm1" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Test</title>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="scriptManager" runat="server" />
        <artem:GoogleMap ID="map" runat="server" Height="100%" Width="100%" Address="Seattle, WA" />
    </form>
</body>
</html>

WebForm1.aspx.cs:

using System;

namespace CleanAir.PlotComplaints
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            this.map.MapType = Artem.Google.UI.MapType.Roadmap;
            this.map.Address = "Seatac, WA";
            this.map.Zoom = 10;

            DrawPointsOfInterest();
        }

        private void DrawPointsOfInterest()
        {
            this.map.Overlays.Add(PointsOfInterest.NonattainmentArea);
        }
    }
}