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>
<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?
To fix the problem, you just need to set ClientIDMode="AutoID" on the control(s) which should trigger the UpdatePanel post back.
A full postback would be when you refresh the entire 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.
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.
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With