AJAX.Net - UpdatePanel does not remove old content

I am using AJAX.Net (3.5) inside usercontrol. Usercontrol contains UpdatePanel and inside UpdatePanelthere there is MultiView. The ScriptManager is included in the page that acts as a container for user control.

The custom control contains a simple button to switch between views. When I click on it, the view changes, so the old content is hidden and the new content is displayed. My problem is that the content is not hidden at all. The view changes and new content is displayed, but the old remains on the page. To isolate the problem, I tried to change the visibility of the multivisor and switch to a simple label, but the behavior remains the same. Any ideas?

0


source to share


3 answers


AJAX.Net doesn't seem to work very well if you have a portion of the table outside the UpdatePanel.

In my control, I want to show or hide some of the table rows. I only included the tr and td tags inside the update panel.

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 is displayed on the page (lblToHide does not hide)

If you move table tags inside the UpdatePanel works fine.

0


source


Oh I understand. Everything is good. The problem here isn't Ajax. You just can't embed something in tags <table>

. In this case, you can try something other than the control <table>

. Maybe <div>

or something else. I don't know exactly what your situation is. Perhaps you can explain the result you want to achieve so that I can give you some advice.



Hello

+1


source


call

updatepanel.Update() 

      

after making changes to your update panel

or try

 updatepanel.Controls.Clear();

      

0


source







All Articles