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 =「自動識別」我的用戶控件標籤解決的問題。

相關問題