注意:UpdatePanel中的ColorPickerExtender会导致完全回发

时间:2016-04-21 17:05:08

标签: asp.net updatepanel obout

我在ColorPickerExtender中有一个严重的UpdatePanel以及其他一些控件。其他控件按预期执行部分回发,但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>

在我提出问题时,我能够找到答案(见下文) - 我把它留在这里供其他人使用,而不是捣乱这个问题。

1 个答案:

答案 0 :(得分:0)

事实证明,ColorPickerExtender未被注册为异步回发控件。我从this post得到了线索。我不确定为什么它在其他人注册时不会注册为异步控件,但修复很容易 - 添加一个明确指定为异步的<Triggers>部分,如下所示:

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