Add a double-click event to the ListBox control in .NET

xiaoxiao2021-03-06  65

I am experiencing a listbox problem in using DOTNET, I have added a ListBox problem: add the selected item to another in another listbox, but the ListBox control itself does not have this event, so how to implement? I thought of the client script JavaScrit, and finally solved this problem by reviewing the relevant information. Now it is written to share with you, I hope to help everyone.

There are three problems here:

First: What is the JavaScript code you want to do?

Note: The syntax of the JavaScript code should be correct, that is, each line is ended;

Function change ()

{

VAR AddOption = Document.createElement ("option");

Var index1;

IF (Document.form1.ListBox1.Length == 0) Return (false);

Index1 = Document.form1.ListBox1.selectedIndIndex;

IF (INDEX1 <0) Return (False);

AddOption.text = document.form1.listbox1.Options (index1) .Text;

AddOption.Value = Document.form1.listbox1.value;

Document.form1.listbox2.add (addoption);

Document.form1.listbox1.remove (Index1);

}

Second: How do you convert JavaScript code to C # code?

Public Static void ListBox_dblclick (page page, system.web.ui.webcontrols.webcontrol webcontrol, string sourcecontrolname, string targetcontrolname)

{

SourceControlName = "Document.form1." SourceControlName;

TargetControlName = "Document.form1." TargetControlName;

String JS = "