I am using the AutoCompleteExtender and I created a web service inside my web project and it works, but my problem is this:
I need the web service to be aware of the selections made in the UI before the CompletionList WebService is called.
I set 'UseContextKey' to true, and created he override method that uses ContextKey, but on the server when a 'Network' is selected I set:
// Set the NetworkID
(The AutoSuggestionControl is the name of the AutoCompleteExtender
this.AutoSuggestionControl.ContextKey
= "NetworkID="+ network.NetworkID.ToString();
My gut feeling is the value is set on the server and the Javascript in the client isn't aware of this
new value because contextKey is null.
My web method is only stubbed out for now, but here it is:
Here is the code for the AjaxExtender:
TargetNameTextBox currently displays 'Person Name' in the label associated with it for the current
'View Type' that is selected.
<ajaxToolkit:AutoCompleteExtender runat="server" ID="AutoSuggestionControl" TargetControlID="TargetNameTextBox" ServiceMethod="GetCompletionList" ServicePath="http://localhost:2222/WebServices/SuggestionsWebService.asmx" MinimumPrefixLength="1" CompletionInterval="200" EnableCaching="false" CompletionSetCount="10" CompletionListCssClass="completionlist" CompletionListItemCssClass="completionlistitem" CompletionListHighlightedItemCssClass="completionlistitemselected" DelimiterCharacters=";, :" ShowOnlyCurrentWordInCompletionListItem="true" UseContextKey="true"></ajaxToolkit:AutoCompleteExtender>
/// <summary> /// Summary description for SuggestionsWebService /// </summary> [System.ComponentModel.ToolboxItem(false)] [System.Web.Script.Services.ScriptService] public class SuggestionsWebService : System.Web.Services.WebService { #region Methods #region GetCompletionList(string prefixText, int count, string contextKey) /// <summary> /// This method returns a list of 'Names' (Users, Subjects or Topics) /// </summary> /// <param name="partialText"></param> /// <param name="count"></param> /// <returns></returns> [WebMethod(EnableSession = true)] [System.Web.Script.Services.ScriptMethod] public string[] GetCompletionList(string prefixText, int count, string contextKey) { // initial value string[] suggestions = null; // Create an instance of the gateway Gateway gateway = new Gateway(); // test only if I set the contextKey the auto complete works // contextKey = "212214"; // if the prefixText exists and the contextKey exists
// (the same as ((!String.IsNullOrEmpty(prefixText)) && (!String.IsNullOrEmpty(context))) if (TextHelper.Exists(prefixText, contextKey)) { // test only hard coded count count = 2; // create the return value suggestions = new string[count]; // Test only suggestions[0] = "Chris Jones"; suggestions[1] = "Cindy Smith"; } // return value return suggestions; } #endregion #endregion }
Is there way for me to get to a Session object or some type of context selections when the web service
fires?
Thanks if you can help