public JavaScriptResult GetScriptByPageName(string pageName) { string javascript = ""; AutoCompleteRepo aRepo = new AutoCompleteRepo(); List <AutocompleteInfo> aList = new List <AutocompleteInfo>(); try { aList = aRepo.GetAutocompletesByPageName(pageName); javascript += "$(function(){ "; foreach (var item in aList) { javascript += "SetAutocomplete('" + item.ControlName + "','" + item.IdFieldName + "','" + item.TextFieldName + "','" + item.TableName + "','" + item.DependentControlName + "','" + item.DependentFieldName + "','" + item.ExtraFields + "');"; javascript += "GetAutocomplete('" + item.ControlName + "','" + item.IdFieldName + "','" + item.TextFieldName + "','" + item.TableName + "','" + item.ExtraFields + "');"; if (!string.IsNullOrEmpty(item.DependentControlName) && item.IsMultiselect != true) { foreach (var itm in item.DependentControlName.Split(',')) { javascript += "$(\"[name='" + itm + "']\").change(function(){"; javascript += "$(\"[name='" + item.ControlName + "']\").html('');"; javascript += "});"; } } } javascript += "});"; } catch (Exception ex) { } return(JavaScript(javascript)); }
public List <AutocompleteInfo> GetAutocompletesByPageName(string ControllerName) { return(_autoCompleteRepo.GetAutocompletesByPageName(ControllerName)); }