AJAX.NET 订阅Reorderlist ItemCommand 或DeleteCommand?
我想订阅我的页面上的重新排序列表的 ItemCommand 事件。 前端看起来像这样...
<cc1:ReorderList id="ReorderList1" runat="server" CssClass="Sortables" Width="400" OnItemReorder="ReorderList1_ItemReorder" OnItemCommand="ReorderList1_ItemCommand">
...
<asp:ImageButton ID="btnDelete" runat="server" ImageUrl="delete.jpg" CommandName="delete" CssClass="playClip" />
...
</cc1:ReorderList>
在后端我在 Page_Load 上有这个
ReorderList1.ItemCommand += new EventHandler<AjaxControlToolkit.ReorderListCommandEventArgs>(ReorderList1_ItemCommand);
并且定义了这个函数
protected void ReorderList1_ItemCommand(object sender, AjaxControlToolkit.ReorderListCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.CommandName == "delete")
{
//do something here that deletes the list item
}
}
}
尽管我尽了最大努力,但我似乎无法触发这个事件。 如何在 ReorderList 控件中正确订阅此事件?
I would like to subscribe to the ItemCommand event of a Reorderlist I have on my page. The front end looks like this...
<cc1:ReorderList id="ReorderList1" runat="server" CssClass="Sortables" Width="400" OnItemReorder="ReorderList1_ItemReorder" OnItemCommand="ReorderList1_ItemCommand">
...
<asp:ImageButton ID="btnDelete" runat="server" ImageUrl="delete.jpg" CommandName="delete" CssClass="playClip" />
...
</cc1:ReorderList>
in the back-end I have this on Page_Load
ReorderList1.ItemCommand += new EventHandler<AjaxControlToolkit.ReorderListCommandEventArgs>(ReorderList1_ItemCommand);
and this function defined
protected void ReorderList1_ItemCommand(object sender, AjaxControlToolkit.ReorderListCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.CommandName == "delete")
{
//do something here that deletes the list item
}
}
}
Despite my best efforts though, I can't seem to get this event to fire off. How do you properly subscribe to this events in a ReorderList control?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这有效:
代码隐藏:
this works:
code behind:
由于您的 ImageButton 的
CommandName="delete"
您应该连接到 DeleteCommand 事件而不是 ItemCommand。Since your ImageButton's
CommandName="delete"
you should be hooking up to the DeleteCommand event instead of ItemCommand.