我可以双击asp.net listview吗?我想在双击而不是单一的ItemCommand上调用函数。
有可能吗?
的Ta!
答案 0 :(得分:0)
如果调用函数指的是server side
,则调用简单的事情就是
private void listView_MouseDoubleClick(object sender, MouseEventArgs e)
{
MessageBox.Show("Double Click Event Called");
}
有关同一检查的更多信息:
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doubleclick.aspx
如果调用函数引用任何client side (Javascript/Jquery call)
,那么您可以使用:
$('#target').dblclick(function() {
alert('Handler for .dblclick() called.');
})
了解详情here
答案 1 :(得分:0)
ASPX:
<asp:ListView ID="ListView1" runat="server"
onitemdatabound="ListView1_ItemDataBound" onitemcommand="ListView1_ItemCommand">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" CommandName="DoubleClick" runat="server">LinkButton</asp:LinkButton>
</ItemTemplate>
</asp:ListView>
CS:
protected void ListView1_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
LinkButton LinkButton1 = (LinkButton)e.Item.FindControl("LinkButton1");
string _jsDouble = ClientScript.GetPostBackClientHyperlink(LinkButton1, "");
LinkButton1.Attributes["ondblclick"] = _jsDouble;
LinkButton1.Attributes["onclick"] = "return false;";
}
}
protected void ListView1_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "DoubleClick")
{
}
}