Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

User control inside update panel causing full page postback

I have a user control with linkbuttons (used for paging) and a repeater inside an update panel. The paging works correctly, but is causing a full page postback every time I click through to the next page.

The update panel looks like this:

<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Always">
        <ContentTemplate>
            <asp:Repeater ID="rptOrganizations" runat="server">
                <HeaderTemplate>
                    <table>
                        <thead>
                            <tr>
                                <th>Organization</th>
                                <th>State</th>
                                <th>Accredited Since</th>
                            </tr>
                        </thead>
                    </table>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr>
                        <td>
                            <asp:Literal ID="ltlInstitution" runat="server" />
                        </td>
                        <td>
                            <asp:Literal ID="ltlState" runat="server" />
                        </td>
                        <td>
                            <asp:Literal ID="ltlAccreditedDate" runat="server" />
                        </td>
                    </tr>
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>

            <uc2:RepeaterPaging ID="rpPager" runat="server" PageSize="10" OnNextButtonClickEvent="btnNext_Click" OnPreviousButtonClickEvent="btnPrev_Click" />
        </ContentTemplate>  
    </asp:UpdatePanel>

And the contents of the user control look like this:

<asp:LinkButton ID="btnPrev" runat="server" OnClick="btnPrev_Click">Previous</asp:LinkButton> | 
<asp:LinkButton ID="btnNext" runat="server" OnClick="btnNext_Click">Next</asp:LinkButton> 

&nbsp;&nbsp;
<asp:Literal ID="ltlNumResults" runat="server" /> results returned.

So far, I have tried adding an async postback trigger for the user control, which does cause an async postback but does not update the rest of the text in the update panel. In otherwords, the async postback occurs and the next page shows up, but the original text in the repeater is there as well just below it.

I have also confirmed that I have IDS set on my linkbuttons, since that can trigger a full postback inside an update panel.

I have tried changing the update panel mode (Always, Conditional, ChildrenAsTriggers, etc.).

None of it makes a difference - the only thing that actually causes an async postback is to use the trigger, but then the rest of the content in the update panel is not updated, so I get duplicate content. Any ideas?

like image 458
Neil Avatar asked Jul 13 '10 15:07

Neil


People also ask

How do I stop UpdatePanel from causing the whole page postback?

To fix the problem, you just need to set ClientIDMode="AutoID" on the control(s) which should trigger the UpdatePanel post back.

What is a full page postback?

A full postback would be when you refresh the entire page.

Which control can you use to update part of the page?

By using UpdatePanel controls, you can refresh selected parts of the page instead of refreshing the whole page with a postback. This is referred to as performing a partial-page update.

How do I stop the current asynchronous postback call?

Click the Refresh button again, and when the message appears, click the Cancel link to cancel the postback. This time, the time displayed in the UpdatePanel control does not change, because the asynchronous postback was canceled.


1 Answers

Full postback happens if your UpdatePanel cannot render its contents to a <div> (e.g., when it is situated inside of <tr>). So check you html inside of UpdatePanel, you might find the answer there (also, look for some incorrect xhtml, like incorrectly closed elements).

like image 54
buru Avatar answered Oct 06 '22 08:10

buru