0

我可以双击asp.net listview 吗?我想在双击而不是单击时调用一个函数,即 ItemCommand。

有可能吗?

塔!

4

2 回答 2

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.');
 })

欲了解更多信息,请查看此处

于 2012-12-17T11:54:30.713 回答
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")
        {

        }
    }
于 2012-12-17T11:59:21.657 回答