function openPopUp()
{
// ur code to open the popup
LoadDropDownContent();
}
function LoadDropDownContent()
{
var url = $(this).data('url')// url of ur ActionResult;
var data = //Any data u want to pass on
//get the timestamp
var nocache = new Date().getTime();
//add the timestamp as a paramter to avoid caching
data['nocache'] = nocache;
$.getJSON(url, data, function (items) {
var ddl = $('#urdrpdownid');
ddl.empty();
ddl.append($('<option/>', { value: '', text: '--Selecteer--' }));
$.each(items, function (index, item) {
ddl.append($('<option/>', {
value: item.Value,
text: item.Text,
selected: item.Selected
}));
});
});
}
控制器中的代码
public ActionResult GetItems()
{
var dropdownitems = //ur BL/DAL function to retrieve the list of entity;
var items = dropdownitems.Select(s => new SelectListItem { Text = s.ColName, Value = s.ColName}).AsEnumerable();
return Json(items, JsonRequestBehavior.AllowGet);
}