views:

30

answers:

2
<ajaxtoolkit:AccordionPane ID="accordianPaneAroundTheCheckbox" runat="server">
    <Content>
        <asp:UpdatePanel ID="updatePanelAroundTheCheckbox" runat="server" >
            <ContentTemplate>
                <div>
                    <asp:CheckBox ID="chkFoo" AutoPostBack="true"  runat="server" OnCheckedChanged="DoBar"/>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </Content>
</ajaxtoolkit:AccordionPane>

We have something like the above. Extra stuff has been left off as it is a large page.

I place a breakpoint at the begining of Page_Load and DoBar. The first time I click the checkbox, the breakpoint on Page_Load is hit, but DoBar is not. The second time I click the checkbox, both breakpoints are hit.

Why could this be happening? I'm not dynamically generating the checkbox. It's ClientID is the same every time (no dynamically generated or ID'd containers). I've tried resubscribing to the event in the Page_Load, but it didn't hit the first time, and just hit it subsequent times twice.

Update I have tried removing the UpdatePanel completely. Not only does the whole page postback, which I don't want, but the event is still not entered. What can block/swallow an event call like that? Is there some exception deep in the bowels of a master page or framework call or something somewhere that I can't see?

A: 

Is that the correct source code you've pasted? I'm asking because there's no event called OnCheckChanged, there is however an OnCheckedChanged event. Using your code it works just fine when the markup for the checkbox looks like this:

<asp:CheckBox ID="chkFoo" runat="server" AutoPostBack="true" OnCheckedChanged="DoBar"/>
Tchami
No, that was a typo. I had the correct event. I'm assuming the code you are using that works does not include the Update Panel or Accordian. I left a lot of other controls off an irrelevant, but those are most likely relevant to this behavior.
Andy_Vulhop
Nope, I added an AccordionPane control and an UpdatePanel inside that. I'll post the source later when I get back home. For now, does it make any difference if you add a trigger to your updatepanel?
Tchami
I took the update panel out altogether. Still behaves the same.
Andy_Vulhop
A: 

The checkbox isn't being set by anything on the server side. The form is populated by an ajax call to a PageMethod that pulls a databag from the server and populates the controls. The problem is that the server thought it was unchecked, but javascript checked it. When I unchecked it, the postback happened, and the viewstate still thought its previous state was unchecked, and the current state is now unchecked. Thus, the CheckedChanged event doesn't fire.

A thousand grisly deaths to Viewstate. I'm close enough to fix the issue now. Thanks for trying/looking.

Andy_Vulhop