I've got a dropdown list that is being populated via a webservice using ASP>NET AJAX. On the success callback of the method in javascript, I'm populating the dropdown via a loop:
function populateDropDown(dropdownId, list, enable, showCount)
{
var dropdown = $get(dropdownId);
dropdown.options.length = 1;
for (var i = 0; i < list.length; i++) {
var opt = document.createElement("option");
if (showCount) {
opt.text = list[i].Name + ' (' + list[i].ChildCount + ')';
} else {
opt.text = list[i].Name;
}
opt.value = list[i].Name;
dropdown.options.add(opt);
}
dropdown.disabled = !enable;
}
However when I submit the form that this control is on, the control's list is always empty on postback. How do I get the populated lists data to persist over postback?
Edit: Maybe I'm coming at this backwards. A better question would probably be, how do I populate a dropdown list from a webservice without having to use an updatepanel due to the full page lifecycle it has to run through?