None
None

Reputation: 5670

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?

Upvotes: 0

Views: 297

Answers (2)

Hirav Sampat
Hirav Sampat

Reputation: 196

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>

Upvotes: 1

DavidG
DavidG

Reputation: 118957

In your async trigger, you only need to specify the name of the event, not including the name of the control or the On prefix:

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

Upvotes: 2

Related Questions