更新面板内的用户控制导致整页回发

发布于 2024-09-09 05:59:54 字数 2383 浏览 9 评论 0原文

我有一个带有链接按钮(用于分页)的用户控件和一个更新面板内的中继器。分页工作正常,但每次我单击下一页时都会导致整页回发。

更新面板如下所示:

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

用户控件的内容如下所示:

<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.

到目前为止,我尝试为用户控件添加异步回发触发器,这确实会导致异步回发,但不会更新中的其余文本更新面板。换句话说,异步回发发生并显示下一页,但转发器中的原始文本也位于其下方。

我还确认我在链接按钮上设置了 IDS,因为这可以在更新面板内触发完整回发。

我尝试更改更新面板模式(始终、条件、ChildrenAsTriggers 等)。

这些都没有什么区别 - 真正导致异步回发的唯一原因是使用触发器,但是更新面板中的其余内容没有更新,所以我得到了重复的内容。有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

遗心遗梦遗幸福 2024-09-16 05:59:54

如果您的 UpdatePanel 无法将其内容渲染到

(例如,当它位于 内部时),则会发生完全回发。因此,检查 UpdatePanel 内部的 html,您可能会在那里找到答案(另外,查找一些不正确的 xhtml,例如错误关闭的元素)。

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).

披肩女神 2024-09-16 05:59:54

删除更新模式=“始终”,不要在上面放置任何内容,它应该可以工作。

还有一件事是您将脚本管理器添加到您的页面还是不进行控制?

如果没有脚本管理器,它将无法工作。

Remove the update mode="Always" Don't put anything over that and it should work.

One more thing are you adding script manager to your page or control not?

Without script manager it will not work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文