AJAX.Net - UpdatePanel doesn't delete old content

女生的网名这么多〃 提交于 2019-12-23 05:12:05

问题


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?


回答1:


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




回答2:


call

updatepanel.Update() 

after you make the changes to your updatepanel

or try

 updatepanel.Controls.Clear();



回答3:


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.



来源:https://stackoverflow.com/questions/820218/ajax-net-updatepanel-doesnt-delete-old-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!