2009-11-13 128 views
1

我有一個在asp.net中開發的應用程序,它設置div的innerhtml。我正在創建一個html字符串來顯示googlemap。它工作正常。但是,當我把我的div內更新面板。它不會顯示div中的googlemap。這裏是我的aspx文件代碼:div更新面板innerHTML問題



  </td> 
     </tr> 
     <tr> 
      <td colspan="4"> 
       <asp:UpdatePanel ID="UpdatePanel2" runat="server"> 
        <ContentTemplate> 
         <div id="map_canvas" runat="server" style="width: 100%; height: 1500px; margin-bottom: 2px; 
          text-align: center;"> 
          <asp:Panel ID="Panel1" runat="server"> 
           <%--Place holder to fill with javascript by server side code--%> 
           <asp:Literal ID="js" runat="server"></asp:Literal> 
           <%--Place for google to show your MAP--%> 
           <div id="Div1" style="width: 100%; height: 728px; margin-bottom: 2px;"> 
           </div> 
           <br /> 
          </asp:Panel> 
         </div> 
        </ContentTemplate> 
        <Triggers> 
         <asp:AsyncPostBackTrigger ControlID="btnShow" EventName="Click" /> 
        </Triggers> 
       </asp:UpdatePanel> 
      </td> 
     </tr> 

這裏是我的按鈕單擊事件。

protected void btnShow_Click(object sender, EventArgs e) 
{ 
    // works fine without update panel.  
    map_canvas.InnerHtml = showMapWithPoints(); 
} 

回答

0

當你這樣做:

map_canvas.InnerHtml = showMapWithPoints(); 

您將要覆蓋的一切,包括所有的服務器端控件,在該div內。

你是否在做任何需要這些控件的東西,比如'js'和'div1'控件?