LinkBut​​ton 未触发 Accordion 中的 OnClick 事件

发布于 2024-08-27 23:09:33 字数 1624 浏览 3 评论 0原文

我无法在 LinkBut​​tonDelete_Click 上触发断点。处理 AJAX Accordions 中的按钮有什么技巧吗?谢谢。

<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

使用 ItemCommand 事件:

<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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梨涡 2024-09-03 23:09:33

由于您没有指定谁开发了该控件,因此我基本上猜测其内部功能。但一种可能性是手风琴控件正在消耗来自链接按钮的事件(尽管您明确定义了链接按钮的 onclick 事件处理程序)。

查看手风琴的事件以查看是否存在单击(或类似)事件 。

编辑:

现在,我知道您正在使用哪个手风琴控件,我的下一个问题是您上次刷新的时间 AJAX Control Toolkit 的 DLL?如果已经有一段时间了,那么曾经有一个关于控件正确命名容器的错误,可以在此处找到详细信息:http://ajaxcontroltoolkit.codeplex.com/WorkItem/View.aspx?WorkItemId=11615

它已于五月份修补并修复2009 年。

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.

紫瑟鸿黎 2024-09-03 23:09:33

这确实是一个错误,并已在 AJAX Control Toolkit 版本 3.0.31106.0 中部分修复。由于某种原因需要一个额外的步骤(其他人似乎不需要这个步骤??)。我每次都必须在页面加载时重新数据绑定手风琴,现在它可以完美地工作。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文