Search code examples
.netvb.netajaxaccordionlinkbutton

LinkButton not firing OnClick event in Accordion


I have not been able to get the break point I have on LinkButtonDelete_Click to fire. Is there a trick to dealing with buttons inside of AJAX Accordions? Thank you.

<cc1:Accordion ID="Accordion1" runat="server" DataSourceID="ObjectDataSource1"
   SelectedIndex="-1" RequireOpenedPane="false">
     <HeaderTemplate>
        <asp:Label ID="LabelDisplayName" runat="server" Text='<%#Bind("FirstName") %  
          >'></asp:Label>
     </HeaderTemplate>
     <ContentTemplate>
        <asp:LinkButton ID="LinkButtonDelete" runat="server" 
           OnClick="LinkButtonDelete_Click" Text="Delete"></asp:LinkButton>
        ...
     </ContentTemplate>
 </cc1:Accordion>

Public Sub LinkButtonDelete_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim button As LinkButton = CType(sender, LinkButton)
...
End Sub

Using the ItemCommand Event:

<cc1:Accordion ID="Accordion1" runat="server" DataSourceID="ObjectDataSource1" 
 SelectedIndex="-1" RequireOpenedPane="false"> 
 <HeaderTemplate> 
    <asp:Label ID="LabelDisplayName" runat="server" Text='<%#Bind("FirstName") %   
      >'></asp:Label> 
 </HeaderTemplate> 
 <ContentTemplate> 
    <asp:LinkButton ID="LinkButtonDelete" runat="server"  
       CommandName="Remove" Text="Delete"></asp:LinkButton> 
    ... 
 </ContentTemplate> 
</cc1:Accordion> 

Private Sub Accordion1_ItemCommand(ByVal sender As Object, ByVal e As     
   System.Web.UI.WebControls.CommandEventArgs) Handles Accordion1.ItemCommand
    If e.CommandName = "Remove" Then
        'Do stuff
    End If
End Sub

Solution

  • This is indeed a bug and has been partially fixed in AJAX Control Toolkit Version 3.0.31106.0. An additional step is necessary for some reason (other people seem to not need this step??). I have to re-databind the accordion on page load every single time and it now works flawlessly.