This project is read-only.

UpdatePanels and ITemplates

Mar 18, 2010 at 9:34 PM
Edited Mar 18, 2010 at 9:37 PM

When placing a map control inside a UpdatePanel like this:

 

            <asp:UpdatePanel ID="UpdatePanelMap" runat="server">
                <ContentTemplate>
                    <asp:Panel ID="pnlMap" runat="server" CssClass="innercontent" DefaultButton="btnSearch">
                                               
                        <artem:GoogleMap ID="GoogleMap1" runat="server" Width="440px" Height="440px" Key="xxx"
                            Zoom="13" EnableMarkerManager="true">
                        </artem:GoogleMap>

                    </asp:Panel>
                </ContentTemplate>
            </asp:UpdatePanel>

 

I build my map using an ITemplate-inherited class for the Markers:

GoogleMap1.Markers.Clear();

foreach (Business business in result.Businesses)
{

GoogleMarker marker = new GoogleMarker(business.Address1 + ", " + business.City + ", " + business.State + " " + business.ZipCode);

MarkerBusinessTemplate template = new MarkerBusinessTemplate();
template.Business = business; // Passed in as a custom property so I can dynamically change html within InstantiateIn(Control container)
 marker.InfoWindowTemplate = template; marker.InfoContent.Width = new Unit("300px"); marker.InfoContent.Height = new Unit("300px"); GoogleMap1.Markers.Add(marker); }

After map is populated above (first postback):
<div id="ctl00_ctl00_bodycontent_subbody_GoogleMap1" style="height:440px;width:440px;">

	</div><div id="ctl00_ctl00_bodycontent_subbody_GoogleMap1_Templates" style="display:none;"><div id="Marker0Content">
		<div><div><img src="http://static1.px.yelpcdn.com/bpthumb/RSHQHB0a8AJxXJsVDfcwCg/ms"></img><p style="text-align:center;"><input name="Marker0Content$btnAddFavorite_UTVDbZv-qiHU06sDkoel3g" type="button" id="Marker0Content_btnAddFavorite_UTVDbZv-qiHU06sDkoel3g" value="Add favorite" onclick="AddFavFromMap('UTVDbZv-qiHU06sDkoel3g','4158247166','Chez Maman');" /></p></div><div><a href="http://www.yelp.com/biz/chez-maman-san-francisco" target="_blank">Chez Maman</a><br /><img src="http://static3.px.yelpcdn.com/static/20091130418129184/i/ico/stars/stars_small_4.png" /><span>(600&nbsp;reviews)</span><br /><br /><span>1453 18th Street</span><br /><span>San Francisco&nbsp;CA&nbsp;94107</span><br /><span>415-824-7166</span><br /><br /><a href="http://www.yelp.com/biz/chez-maman-san-francisco" target="_blank">Read the reviews &#187;</a></div></div>
	</div><div id="Marker1Content">
		<div><div><img src="http://static1.px.yelpcdn.com/bpthumb/BQTprac6Hd7A4RAYL9v42Q/ms"></img><p style="text-align:center;"><input name="Marker1Content$btnAddFavorite_hfm5uSUpfhcBYSFYjHQSgw" type="button" id="Marker1Content_btnAddFavorite_hfm5uSUpfhcBYSFYjHQSgw" value="Add favorite" onclick="AddFavFromMap('hfm5uSUpfhcBYSFYjHQSgw','4156266188','KK Cafe');" /></p></div><div><a href="http://www.yelp.com/biz/kk-cafe-san-francisco" target="_blank">KK Cafe</a><br /><img src="http://static3.px.yelpcdn.com/static/20091130418129184/i/ico/stars/stars_small_4.png" /><span>(119&nbsp;reviews)</span><br /><br /><span>252 Divisadero Street</span><br /><span>San Francisco&nbsp;CA&nbsp;94117</span><br /><span>415-626-6188</span><br /><br /><a href="http://www.yelp.com/biz/kk-cafe-san-francisco" target="_blank">Read the reviews &#187;</a></div></div>
	</div><div id="Marker2Content">
		<div><div><img src="http://static1.px.yelpcdn.com/bpthumb/HHvJTFSwSNZsdWDpS7X6Vg/ms"></img><p style="text-align:center;"><input name="Marker2Content$btnAddFavorite_TRBP1G1l8vZkjgfqdx96Cw" type="button" id="Marker2Content_btnAddFavorite_TRBP1G1l8vZkjgfqdx96Cw" value="Add favorite" onclick="AddFavFromMap('TRBP1G1l8vZkjgfqdx96Cw','4154096120','Pearl's Deluxe Burgers');" /></p></div><div class="businessinfo"><a href="http://www.yelp.com/biz/pearls-deluxe-burgers-san-francisco" target="_blank">Pearl's Deluxe Burgers</a><br /><img src="http://static3.px.yelpcdn.com/static/20091130418129184/i/ico/stars/stars_small_4.png" /><span>(559&nbsp;reviews)</span><br /><br /><span>708 Post St</span><br /><span>San Francisco&nbsp;CA&nbsp;94109</span><br /><span>415-409-6120</span><br /><br /><a href="http://www.yelp.com/biz/pearls-deluxe-burgers-san-francisco" target="_blank">Read the reviews &#187;</a></div></div>
	</div><div id="Marker3Content">
		<div><div><img src="http://static1.px.yelpcdn.com/bpthumb/MkBX5E1PTW1UtB6CNrEyzw/ms"></img><p style="text-align:center;"><input name="Marker3Content$btnAddFavorite_RM1ioN-76NzXDbfv63GhTQ" type="button" id="Marker3Content_btnAddFavorite_RM1ioN-76NzXDbfv63GhTQ" value="Add favorite" onclick="AddFavFromMap('RM1ioN-76NzXDbfv63GhTQ','4157717771','Gamine');" /></p></div><div><a href="http://www.yelp.com/biz/gamine-san-francisco" target="_blank">Gamine</a><br /><img src="http://static3.px.yelpcdn.com/static/20091130418129184/i/ico/stars/stars_small_4.png" /><span>(307&nbsp;reviews)</span><br /><br /><span>2223 Union St</span><br /><span>San Francisco&nbsp;CA&nbsp;94123</span><br /><span>415-771-7771</span><br /><br /><a href="http://www.yelp.com/biz/gamine-san-francisco" target="_blank">Read the reviews &#187;</a></div></div>
	</div>

 </div><input id="ctl00_ctl00_bodycontent_subbody_GoogleMap1_State" name="ctl00_ctl00_bodycontent_subbody_GoogleMap1_State" type="hidden" />

After any other postback:

<div id="ctl00_ctl00_bodycontent_subbody_GoogleMap1" style="height:440px;width:440px;">
</div><div id="ctl00_ctl00_bodycontent_subbody_GoogleMap1_Templates" style="display:none;"></div><input id="ctl00_ctl00_bodycontent_subbody_GoogleMap1_State" name="ctl00_ctl00_bodycontent_subbody_GoogleMap1_State" type="hidden" />


I lose my marker content! I retain my markers and position because they are sent using Javascript, but there is no content in their callout bubble. It seems that the control needs to also persist the content along with the other data.

Mark