Click here to Skip to main content
15,909,030 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

Autocomplete extender returning the following error in firebug.

{"Message":"Authentication failed.","StackTrace":null,"ExceptionType":"System.InvalidOperationException"}


My method is asmx file:

XML
[WebMethod]
   public static List<string> SearchCities(string prefixText,int count, string contextKey)
   {
       Util utility = new Util();
       List<string> CityList = new List<string>();
       CityList = utility.GetCities(prefixText,contextKey);
       return CityList;
   }



XML
<asp:TextBox runat="server" ID="txtOfficeCity" onkeyup="SetOfficeContextKey()" />
                                                                                                            <asp:HiddenField ID="hfOfficeCityCode" runat="server" />
                                                                                                            <cc1:AutoCompleteExtender
                                                                                                                runat="server" ID="Auto2"
                                                                                                                TargetControlID="txtOfficeCity"
                                                                                                                EnableCaching="true"
                                                                                                                CompletionListCssClass="completionList"
                                                                                                                CompletionListItemCssClass="listItem"
                                                                                                                CompletionListHighlightedItemCssClass="itemHighlighted"
                                                                                                                ServiceMethod="SearchCities"
                                                                                                                ServicePath="AutoComplete.asmx"
                                                                                                                OnClientItemSelected="ClientOfficeCitySelected"
                                                                                                                MinimumPrefixLength="1"
                                                                                                                UseContextKey="true"
                                                                                                                CompletionInterval="10"
                                                                                                                 CompletionSetCount="12">
                                                                                                            </cc1:AutoCompleteExtender>



Javascript methods for setting and getting the context keys.
JavaScript
function SetOfficeContextKey() {
           $find("<%=Auto2.ClientID %>").set_contextKey($get("<%=ddlCountryOffice.ClientID %>").value);
       }

function ClientOfficeCitySelected(sender, e) {
           debugger;
           $get("<%=hfOfficeCityCode.ClientID %>").value = e.get_value();
       }
Posted

 
Share this answer
 
v3
Comments
VICK 24-Oct-13 7:37am    
Where is the Link Vinodh.B???
Vinodh.B 24-Oct-13 7:48am    
Missed the link . pls find the updated solution .
VICK 24-Oct-13 7:51am    
Thanks Vinodh.
Hi,


Removed the static keyword and it worked.

XML
[WebMethod]
   public  List<string> SearchCities(string prefixText,int count, string contextKey)
   {
       Util utility = new Util();
       List<string> CityList = new List<string>();
       CityList = utility.GetCities(prefixText,contextKey);
       return CityList;
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900