views:

1144

answers:

5

I have a custom server control that seems to work fine until I put it in an UpdatePanel. Once inside the UpdatePanel it continues to work fine but the UpdatePanel now does full postbacks when my custom server control does a postback.

Do I need to do anything to make my custom server control do async postbacks while inside an UpdatePanel?

Here is the relevant code that is causing a full postback. The ecs:Pager control is my custom control that causes full postbacks on the OnCommand event even though it is in the UpdatePanel.

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

Sorry...can't see the rest of the page.

Do you have a ScriptManager on your page, as well?

Steve J
Yes, sorry the code got cut off for some reason. Fixed now. ScriptManager is present as part of the Master Page.
DarenTx
A: 

Does the custom control implement INamingContainer, and is the postback coming from another control inside that naming container?

I found a naming container boundary between the UpdatePanel and the source control can cause this behavior.

David
A: 

One option might be as AndreasKnudsen suggests as adding an AsyncPostBackTrigger to your panel

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

Another option is to try adding ChildrenAsTriggers to your UpdatePanel tag

<asp:UpdatePanel ID="ClosedIssuesUpdatePanel" runat="server" ChildrenAsTriggers="true">
Adam Fox
ChildrenAsTriggers is true as default, so adding this would not be any different.
awe
+1  A: 

Put the update mode of your update panel to conditional.

<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>
Cédric Boivin
+1  A: 

You don't specify what kind of controls are being used in your custom control. Are they buttons or drop downs or something else? If they're buttons, you need to make sure that their UseSubmitBehavior properties are set to False.

Also, you're going to want to register your controls with the page's ScriptManager via ScriptManager.RegisterAsyncPostBackControl

rossisdead