I have a button sitting inside a control inside an update panel that is not posting back to the server and I cannot figure out why.
The button is simply an normal asp:button:
<asp:Button ID="btnContinue" runat="server" CssClass="close-reveal-modal button-primary" Text="Continue"></asp:Button>
I register its click event on load of the user control:
btnContinue.Click += new EventHandler(btnContinue_Click);
The control containing the button is the BestAvailable control on this page, in this UpdatePanel:
<asp:UpdatePanel runat="server" ID="updatePnlBestAvailable" class="best-available" ChildrenAsTriggers="true">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnReserve" EventName="Click" />
</Triggers>
<ContentTemplate>
<uc:BestAvailable runat="server" ID="BestAvailableControl"></uc:BestAvailable>
<div id="bestAvailablePanelControls">
<asp:Button runat="server" Style="display: none;" ID="ChangeButton"
OnClick="Change_Click" ClientIDMode="static"
CssClass="ChangeButton" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
The postback on the button isn't occurring at all, I have a breakpoint on the first line in my click event handler and it's never hit. According to my co-workers, this is because the button is in the aforementioned update panel. I've tried several things to fix this problem without success.
I attempted to add the button id and a PostBackTrigger to my update panel like so from with in the user control and the containing control:
UpdatePanelControlTrigger trigger = new PostBackTrigger(); trigger.ControlID = this.BestAvailableControl.btnContinue.UniqueID; updatePnlBestAvailable.Triggers.Add(trigger);The result was an exception saying
A control with ID '<unique id prefix>$btnContinue' could not be found for the trigger in UpdatePanel 'updatePnlBestAvailable'.I also attempted to register the control directly in the mark up with the same result.I tried wrapping the button in its own update panel following this post: Custom User Control in UpdatePanel forcing Postback. This made no difference in behavior that I could see.
I'm not very familiar with update panels so I'm running out of ideas. Does anybody know why my button is not posting back to the server?