div insideHTML 与 updatepanel 的问题

发布于 2024-08-10 21:36:09 字数 1797 浏览 2 评论 0原文

我有一个在asp.net中开发的应用程序,它设置了div的innerhtml。我正在创建一个 html 字符串来显示 googlemap。效果很好。但是当我将 div 放入更新面板时。它不在 div 中显示 googlemap。这是我的 aspx 文件代码:



            </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();
}

I have an application developed in asp.net which set innerhtml of div. I am creating an html string to show googlemap. It works fine. But when I put my div inside update panel. it doesnt show googlemap in div. Here is my aspx file code:

            </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>

here is my button click event.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

差↓一点笑了 2024-08-17 21:36:09

当您这样做时:

map_canvas.InnerHtml = showMapWithPoints();

您将覆盖该 div 中的所有内容,包括所有服务器端控件。

您是否正在执行任何需要这些控件可用的操作,例如“js”和“div1”控件?

When you do:

map_canvas.InnerHtml = showMapWithPoints();

You are overwriting everything, including all your server side controls, within that div.

Are you doing anything that requires those controls to be available such as you 'js' and 'div1' controls?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文