views:

888

answers:

3

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?

A: 

call

updatepanel.Update()

after you make the changes to your updatepanel

or try

 updatepanel.Controls.Clear();
DaDa
updatepanel.Update(); doesn't solve the problem.updatepanel.Controls.Clear(); deletes the new content before it is shown, but the old content stays where it was (the page does not change)
nicoruy
can you give your source here
DaDa
A: 

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.

nicoruy
Doesn't the UpdatePanel render a div to the browser? If so, that might explain the issue you are seeing.
Richard Ev
Yes. Every UpdatePanel renders inside a div :(
nicoruy
+1  A: 

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

DaDa
On my real code I have a MultiView inside the table.I use different views to change the rows on the table.When I change the view, I want to see the new rows and hide the old ones. If I include the table inside the UpdatePanel everything works fine (the entire table is updated I think)
nicoruy