views:

731

answers:

2

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

Since you're not specifying who developed this control, I'm basically guessing as to the inner functionality. But one possibility is that the event from the link button is being consumed by the accordion control (despite the fact that you are explicitly defining the linkbutton's onclick event handler.

Look at the accordion's events to see if there is a click (or similar) event accessible that you can code against.

EDIT:

Okay. Now, that I know which accordion control you're using, I know a bit more. My next question is when was the last time that you refreshed the AJAX Control Toolkit's DLLs? If it has been a while, then there was at one time a bug regarding proper naming containers for the control. The details of this can be found here: http://ajaxcontroltoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=11615

It was patched and fixed back in May of 2009.

Stephen Wrighton
There is, the ItemCommand event. But that event does not fire either when clicking the LinkButton. I can post an example of code using that if you would like.
lampej
I'll look at it if you post it, but it may be a low-level action hiding inside the accordion control (i.e. the posts not being raised properly, naming issues, etc) as well. Does the control work correctly with GET requests (i.e. standard hyperlinks)?
Stephen Wrighton
Regarding your intial comment about not specifying who developed this control, I didn't realize what you meant at first but now I do - this is an AJAX control from the AJAX Control Toolkit, not a home built control. Because of that, I figure there is a fair amount of knowledge about it out there.
lampej
See my edits for the ItemCommand event. An ASP Hyperlink does work inside of the Accordion, so worst case scenario I can use a get query to accomplish my goal but I really don't want to.
lampej
I found that bug report already and checked actually. The version of the toolkit I'm using is the version released immediately after that fix was made.
lampej
Sorry, I'm at a loss. The examples that you posted look correct.
Stephen Wrighton
A: 

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.

lampej