I have been digging around a bit looking for a good example of how to take a radcombobox and populate it using a webmethod and jquery combined... I think I am just missing something rather simple.. Any suggestions?
This is NOT a mvc project, but a traditional asp.net web forms
The Control :
The web method:
This is NOT a mvc project, but a traditional asp.net web forms
// This cancels the default RadComboBox behavior function itemsRequesting(sender, args) { if (args.set_cancel != null) { args.set_cancel(true); } if (sender.get_emptyMessage() == sender.get_text()) sender.set_text("");}function getSites(sender, args) { var url = baseUrl + "TagManagement/Tags.aspx/GetSiteList"; $.ajax({ async: false, type: "POST", url: url, data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (msg) { if (msg.d == null) { alert("The filter set returned no records"); } else { fillCombo(sender, msg); } } }).complete(function () { $.unblockUI(); });return false;}function fillCombo(combo, result) { combo.clearItems(); var items = result.d || result; // This just lets user know that nothing was returned with their search if (items.length == 0) { var comboItem = new Telerik.Web.UI.RadComboBoxItem(); comboItem.set_text("Nothing found"); comboItem.set_value("null"); combo.get_items().add(comboItem); combo.set_text(""); } for (var i = 0; i < items.length; i++) { var item = items[i]; var comboItem = new Telerik.Web.UI.RadComboBoxItem(); comboItem.set_text(item.Text); comboItem.set_value(item.Value); combo.get_items().add(comboItem); }}The Control :
<telerik:RadComboBox ID="RadComboBoxTransferSites" runat="server" CheckBoxes="true" EnableLoadOnDemand="true" OnClientItemsRequesting="getSites" EnableCheckAllItemsCheckBox="true" DataTextField="SiteName" DataValueField="SiteUID" EmptyMessage="Please Select..."> </telerik:RadComboBox>The web method:
[WebMethod]public static List<SiteList> GetSiteList(){ var siteList = (List<SiteList>)HttpContext.Current.Session["SiteList"]; return siteList.ToList();}