ASP.NET Call Command Button from Javascript/HTML

In ASP.NET you need to call a button click event event from another control, or to take some type of action in the code behind.

The example below adds a double click event to an ASP.NET ListBox and calls a ASP.NET command button.

//Setup a string that will call a 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