function insert(el, ins) {
if (el.setSelectionRange) {
el.value = el.value.substring(0, el.selectionStart) + ins + el.value.substring(el.selectionStart, el.selectionEnd) + el.value.substring(el.selectionEnd, el.value.length);
}
else if (document.selection && document.selection.createRange) {
el.focus();
var range = document.selection.createRange();
range.text = ins + range.text;
}
}
function Updatelist() {
var sel = document.getElementById(listboxID);
var listLength = sel.options.length;
for (var i = 0; i < listLength; i++) {
if (sel.options[i].selected) {
return sel.options[i].value;
}
}
}
Finally add
listboxid.Attributes.Add("Onclick", "insert(" + txtid.ClientID + ",Updatelist())"); in .cs page