AutoCompleteExtender is firing, webservice is retu

2019-06-01 06:51发布

问题:

I have been banging my head against the desk over this one.

I have added a AutoCompleteExtender to my webpage, and have implemented the webservice method for it to call. So far, so good.

Using Fiddler, I have checked that, when debugging, the webservice method is being called and is returning the results I'd expect to see.. but nothing gets rendered to the screen, there is no drop down?

Can anyone here suggest what I might have done wrong, or offer a suggestion for something to try as I am currently stumped:

Declaration of the AutoCompleteExtender in the webpage:

<cc1:AutoCompleteExtender runat="server" ID="lookupAgencyAppSettingName" TargetControlID="txtAgencyAppSettingName" ServiceMethod="GetListOfSettings"
ServicePath="~/Authenticated/AJAXMethods.asmx" MinimumPrefixLength="1" CompletionInterval="500" EnableCaching="true" />

For completeness, here is the Webservice Method:

[System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public string[] GetListOfSettings(string prefixText, int count)
    {
        string[] suggestedSettings = new string[0];
        List<string> settingNames = new List<string>();
        List<AgencyApplicationClientSetting> settings = AgencyApplicationClientSetting.All().ToList<AgencyApplicationClientSetting>();
        foreach(AgencyApplicationClientSetting setting in settings)
        {
            if((setting.SettingName.ToLower().StartsWith(prefixText.ToLower())) && (!settingNames.Contains(setting.SettingName)))
            {
                settingNames.Add(setting.SettingName);
            }
        }
        if(settingNames.Count > 0)
        {
            suggestedSettings = settingNames.ToArray();
        }
        return suggestedSettings;
    }

回答1:

Okay, in the end this turned out (somewhat annoyingly) a z-index time. I'm not sure what z-index a dialog that is displayed using the AjaxControlToolkit's ModalPopupExtender is given by default (the highest z-index I could see on the page was 10001).. but somewhere behind the scenes it was being given an attribute that meant that my popup suggestions (from the AutoCompleteExtender) always rendered behind the dialog (couldn't see this however until I returned enough results to get the suggestions apepar from beneath the dialog). In the end I had to override the z-index of the panel used as a dialog by the ModalPopupExtender AND the CompletionListCssClass of the AutoCompleteExtender thus:

            .popUpDialog
        {
            z-index: 99 !important;
        }

        .autoComplete_listMain
        {
            z-index: 2147483647 !important;
            background: #ffffff;
            border: solid 2px #808080;
            color: #000000;
        }

Anyway, annoyingly simple in the end, but thought I'd share just in case anyone else runs into a similar problem!