ASP.NET Add Double Click to ListBox

You have an ASP.NET ListBox and you want to be able to allow users to Double Click on the list box to select items.  You can add a hidden button to your page and then add a double click event to the list box to select items as shown below.

//Setup a string that will call a hidden button click event
string BntListBoxClick =  "document.getElementById('" 
                               + BtnAddToTarget.ClientID.ToString() + "')" 
                               + ".click();";

//Add the double click event to the list box
LBoxSelectItems.Attributes.Add("OnDblClick", BntListBoxClick);
Comments are closed