问题
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