简体   繁体   中英

Error with ASP.Net UpdatePanel

My code is like this

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

All looks good to me, but this throws an error

 Could not find an event named 'cbCoaching_OnCheckedChanged' on associated control 'cbCoaching' for the trigger in UpdatePanel ''.

Can anyone point out what I am doing wrong?

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

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

You have to give the name of the event in the trigger and not the name of the function

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM