– Implement an AjaxMethod to return IDictionary object
[AjaxPro.AjaxMethod]
public IDictionary AjaxGetIDictionary()
{
//Prepare the IDictionary object
}
– Use JavaScript to request the AjaxMethod AjaxGetIDictionary
MyAjaxClass. AjaxGetIDictionary (jsAjaxGetIDictionary_Callback);
– In the JavaScript function jsAjaxGetIDictionary_Callback add the IDictionary items to the DopDownList
function jsAjaxGetIDictionary (response)
{
try
{
var DictionaryItems= response.value;
if (DictionaryItems == null || typeof(DictionaryItems) != “object”)
{
return;
}
var myDropDownList = document.getElementById(“myDropDownList”);
myDropDownList.options.length = 0;
for (var i = 0; i < response.value.length; ++i)
{
myDropDownList.options[myDropDownList.options.length] = new Option(response.value[i].Value,response.value[i].Key);
}
}
catch(e)
{
}
}