AJAX.Net - UpdatePanel 不会删除旧内容

发布于 2024-07-19 01:03:54 字数 289 浏览 7 评论 0原文

我在用户控件中使用 AJAX.Net (3.5)。 用户控件包含一个UpdatePanel,并且在UpdatePanel内部有一个MultiView。 ScriptManager 包含在页面中,充当用户控件的容器。

为了在视图之间切换,用户控件包含一个简单的按钮。 当我单击它时,视图会发生更改,因此旧内容会被隐藏并显示新内容。 我的问题是内容根本没有隐藏。 视图发生变化并显示新内容,但旧内容仍保留在页面上。 为了隔离问题,我尝试更改多视图并切换简单标签的可见性,但行为是相同的。 有任何想法吗?

I'm using AJAX.Net (3.5) inside a usercontrol.
The usercontrol contains an UpdatePanel, and inside the UpdatePanelthere is a MultiView.
The ScriptManager is included in the page that act as container for the usercontrol.

To switch between views the usercontrol contains a simple button.
When I click it, the View is changed so the old content is hidden and new content is displayed.
My problem is that the content isn't hidden at all.
The view changes and the new content is displayed, but the old one remains on the page.
To isolate the problem, I tried changing the multiview and switching visibility of a simple label, but the behavior is the same.
Any ideas?

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

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

发布评论

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

评论(3

一瞬间的火花 2024-07-26 01:03:54

哦,我懂。 那就没事了。 问题不在于Ajax。 只是您不能在 标记中嵌入某些内容。 在这种情况下,您可以尝试与

控件不同的操作。 也许是

或其他东西。 我不知道你具体属于哪种情况。 也许你解释一下你想要达到的结果,这样我就可以给你一些建议。

问候

oh I understand. It's all right then. The problem is not of Ajax here. It's just you cannot embed something in <table> tags. In this case, you can try something different than the <table> control. Maybe a <div> or something else. I don't know exactly what sort of situation you have. Maybe you explain the result you want to achieve so I can give you some advice.

Regards

最舍不得你 2024-07-26 01:03:54

如果您的表的一部分位于 UpdatePanel 之外,AJAX.Net 似乎不能很好地工作。

在我的控件上,我想显示或隐藏表格的某些行。 我在 updatepanel 中仅包含 trtd 标签。

重现该问题:

<table>
<asp:UpdatePanel ID="UpdatePanel" runat="server">
    <ContentTemplate>
        <tr>
            <td>
                <asp:Label ID="lblToShow" runat="server" Text="Label to show" Visible="false" />
                <br />
                <asp:Label ID="lblToHide" runat="server" Text="Label to hide" />
            </td>
        </tr>
    </ContentTemplate>
</asp:UpdatePanel>
</table>

如果您使用以下方法更改可见性:

lblToShow.Visible = true;
lblToHide.Visible = false;

两个标签的文本均显示在页面上(lblToHide 不会隐藏)

如果您将 table 标签移至 内部 UpdatePanel 一切正常。

It seems that AJAX.Net doesn't work very well if you have part of a table outside the UpdatePanel.

On my control I want to show or hide some rows of a table. I included only the tr and td tags inside the updatepanel.

To reproduce the problem:

<table>
<asp:UpdatePanel ID="UpdatePanel" runat="server">
    <ContentTemplate>
        <tr>
            <td>
                <asp:Label ID="lblToShow" runat="server" Text="Label to show" Visible="false" />
                <br />
                <asp:Label ID="lblToHide" runat="server" Text="Label to hide" />
            </td>
        </tr>
    </ContentTemplate>
</asp:UpdatePanel>
</table>

If you change the visibility using:

lblToShow.Visible = true;
lblToHide.Visible = false;

The text of both labels are shown on the page (lblToHide does not hide)

If you move the table tags inside the UpdatePanel everything works fine.

寒冷纷飞旳雪 2024-07-26 01:03:54

致电

updatepanel.Update() 

对更新面板进行更改后

或尝试

 updatepanel.Controls.Clear();

call

updatepanel.Update() 

after you make the changes to your updatepanel

or try

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