obout:ColorPickerExtender 在 UpdatePanel 中导致完全回发

obout:ColorPickerExtender in UpdatePanel causes full postback

我在 UpdatePanel 中有一个对象 ColorPickerExtender 以及其他一些控件。其他控件按预期执行部分回发,但 ColorPickerExtender 尽管在 UpdatePanel 中执行完整回发。这是相关的 ASPX:

<asp:Content ContentPlaceHolderID="cphMainDivContentPlaceHolder" runat="server">
    <asp:UpdatePanel ID="upGeneralLayoutData" runat="server">
        <ContentTemplate>
            <asp:TextBox ID="txtLayoutName" runat="server" 
                ToolTip="Enter a name for this layout (recommend you use a unique name)" 
                OnTextChanged="txtLayoutName_TextChanged" 
                AutoPostBack="true" 
                MaxLength="255" />
            <obout:ColorPickerExtender ID="cpeLayoutBackgroundColor" runat="server" 
                OnClientOpen="onColorPickerExtenderOpen" 
                AutoPostBack="true" 
                TargetProperty="style.backgroundColor" 
                OnColorPostBack="cpeLayoutBackgroundColor_ColorPostBack" 
                PopupButtonID="txtLayoutBackgroundColor" 
                TargetControlID="txtLayoutBackgroundColor" 
                HexView="False" 
                PickButton="False" />
            <asp:TextBox ID="txtLayoutBackgroundColor" runat="server" 
                ToolTip="Select the background color for this layout" 
                CssClass="ColorPickerExtenderTextBox" 
                style="cursor: pointer" 
                Width="50" 
                ReadOnly="True" />
            <br />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>

在构思问题时,我找到了答案(见下文)——我没有将问题丢弃,而是留在这里供其他人使用。

原来 ColorPickerExtender 没有被注册为异步回发控件。我从 this post 得到了线索。我不确定为什么它不注册为异步控件而其他人注册为异步控件,但修复很简单——添加一个 <Triggers> 部分明确将其指定为异步,如下所示:

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="cpeLayoutBackgroundColor" EventName="ColorPostBack" />
</Triggers>