protected void Page_Load(object sender, EventArgs e) { //if (!Page.IsPostBack) //{ // ctlCountryAutoComplete.BehaviorID = UniqueID; //} short countryId = UIHelper.ParseShort(CountryId); short langId = UIHelper.ParseShort(LanguageId); DbCountryAutoCompleteParameter parameter = new DbCountryAutoCompleteParameter(); parameter.LanguageId = langId; parameter.CountryId = countryId; JavaScriptSerializer serializer = new JavaScriptSerializer(); ctlCountryAutoComplete.ContextKey = serializer.Serialize(parameter); ctlCountryAutoComplete.UseContextKey = true; }
public string[] GetCountryList(string prefixText, int count, string contextKey) { JavaScriptSerializer serializer = new JavaScriptSerializer(); // AutoCompleteParameter is a ValueObject DTO that used in AutoComplete only DbCountryAutoCompleteParameter parameter = serializer.Deserialize <DbCountryAutoCompleteParameter>(contextKey); // Retreive Query Object from Spring IDbCountryLangQuery dbCountryLangQuery = (IDbCountryLangQuery)ContextRegistry.GetContext().GetObject("DbCountryLangQuery"); IList <CountryLang> CountryList = dbCountryLangQuery.FindAutoComplete(prefixText, parameter.CountryId ?? -1, parameter.LanguageId ?? -1); List <string> items = new List <string>(CountryList.Count); foreach (CountryLang Country in CountryList) { string item = AutoCompleteExtender.CreateAutoCompleteItem(Country.CountryName, serializer.Serialize(Country)); items.Add(item); } return(items.ToArray()); }