6

我有一个自定义服务器控件,似乎工作正常,直到我把它放入UpdatePanel。一旦进入UpdatePanel,它将继续正常工作,但是当我的自定义服务器控件执行回发时,UpdatePanel现在会执行完整回发。自定义服务器控件导致UpdatePanel内完整回发

我是否需要做任何事情来让自定义服务器控件在UpdatePanel中执行异步回发?

以下是导致完整回发的相关代码。 ecs:Pager控件是我的自定义控件,即使它位于UpdatePanel中,也会导致OnCommand事件的完整回发。

<asp:UpdatePanel ID="ClosedIssuesUpdatePanel" runat="server"> 
    <ContentTemplate> 
     <ecs:Pager ID="ClosedIssuesPager" OnCommand="ClosedIssuesPager_Command" runat="server" /> 
     <asp:Repeater ID="ClosedIssuesRepeater" runat="server"> 
     .... 
     </asp:Repeater> 
    </ContentTemplate> 
</asp:UpdatePanel> 
+0

我也会对这个问题的答案感兴趣。我有一个自定义控件实现IPostBackDataHandler,它不会在UpdatePanel中进行部分回发。当你使用UseChildrenAsTriggers属性时,必须有一些秘密特性让控件被注册为触发器。 – 2009-07-27 22:12:49

+0

如果在updatepanel上添加一个显式触发器以对customcontrol的事件执行异步回发,会发生什么情况? – AndreasKnudsen 2009-07-31 18:15:02

回答

0

对不起...看不到页面的其余部分。

你的页面上还有ScriptManager吗?

+0

是的,抱歉,代码因某种原因被切断。现在修复。 ScriptManager作为主页面的一部分存在。 – DarenTx 2009-06-02 20:11:34

0

自定义控件是否实现了INamingContainer,并且是从命名容器内的另一个控件返回的回传?

我发现UpdatePanel和源代码控件之间的命名容器边界可能导致此行为。

0

一种选择可能是因为AndreasKnudsen表明作为添加AsyncPostBackTrigger到面板

<asp:UpdatePanel ID="ClosedIssuesUpdatePanel" runat="server"> 
    <ContentTemplate> 
    <ecs:Pager ID="ClosedIssuesPager" OnCommand="ClosedIssuesPager_Command" runat="server" /> 
    <asp:Repeater ID="ClosedIssuesRepeater" runat="server"> 
     .... 
    </asp:Repeater> 
    </ContentTemplate> 
    <Triggers> 
    <AsyncPostBackTrigger ControlID="ClosedIssuesPager" EventName="Command" /> 
    </Triggers> 
</asp:UpdatePanel> 

另一种方法是尝试添加ChildrenAsTriggers到您的UpdatePanel标签

<asp:UpdatePanel ID="ClosedIssuesUpdatePanel" runat="server" ChildrenAsTriggers="true"> 
1

把你更新的更新模式面板条件。

<asp:UpdatePanel ID="ClosedIssuesUpdatePanel" runat="server" UpdateMode="Conditional"> 
    <ContentTemplate> 
     <ecs:Pager ID="ClosedIssuesPager" OnCommand="ClosedIssuesPager_Command" runat="server" /> 
     <asp:Repeater ID="ClosedIssuesRepeater" runat="server"> 
     .... 
     </asp:Repeater> 
    </ContentTemplate> 
</asp:UpdatePanel> 
1

您不指定自定义控件中正在使用哪种控件。他们是按钮或下降或别的东西?如果它们是按钮,则需要确保其UseSubmitBehavior属性设置为False。

而且,你会希望通过ScriptManager.RegisterAsyncPostBackControl

1

与页面的ScriptManager注册您的控件我也有类似的问题,发现添加属性的ClientIDMode =“自动识别”我的用户控件标签解决的问题。

相关问题