Error with ASP.Net UpdatePanel

本文关键字:UpdatePanel Net ASP with Error | 更新日期: 2023-09-27 18:15:25

代码是这样的

<asp:Repeater ID="rptEvaluationInfo" runat="server">
<ItemTemplate>
    <li>
        <div class="evaluation-role">
            <span><%#Eval("CampCode") %><br />
                <%#Eval("VolunteerRole") %></span>
        </div>
        <div class="check">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                <ContentTemplate>
                    <label>
                        <asp:CheckBox runat="server" ID="cbUseScore" value="use_score" OnCheckedChanged="cbUseScore_OnCheckedChanged" />
                        Use Score
                    </label>
                    <label>
                        <asp:CheckBox runat="server" ID="cbCoaching" value="coaching-required" OnCheckedChanged="cbCoaching_OnCheckedChanged" />
                        Coaching Required
                    </label>
                </ContentTemplate>
                <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="cbCoaching" EventName="cbCoaching_OnCheckedChanged" />
                </Triggers>
            </asp:UpdatePanel>
        </div>
    </li>
</ItemTemplate>

一切看起来都很好,但是这会抛出一个错误

 Could not find an event named 'cbCoaching_OnCheckedChanged' on associated control 'cbCoaching' for the trigger in UpdatePanel ''.
谁能指出我做错了什么?

Error with ASP.Net UpdatePanel

在异步触发器中,您只需要指定事件的名称,不包括控件的名称或On前缀:

<asp:AsyncPostBackTrigger ControlID="cbCoaching" EventName="CheckedChanged" />

必须给出触发器中事件的名称而不是函数的名称

<Triggers>
    <asp:AsyncPostBackTrigger ControlID="cbCoaching" EventName="CheckedChanged" />
</Triggers>