Passing a parameter to the autocomplete extender service method

by dotnetpete 24. September 2008 17:26

This is something that I've been meaning to delve into for a while now. I've used the AjaxControlToolkit AutoCompleteExtender a bit but until now I have never had to pass a runtime parameter through to the service method.

I found a post saying that the signature of the method must be the following: 

[WebMethod] public string[] GetCountryOrStatesInfo(string prefixText, int count, string contextKey)

For some reason I took the signature part to mean parameters string, int, and string in that order. As it turns out the parameters must be named exactly prefixText, count and contextKey. You will also need UseContextKey="true" on the AutoCompleteExtender in your aspx as well.

In the example I was doing, the context key was state and on the selected index changed of a combo I was setting the context like this:

AutoCompleteExtender1.ContextKey = ddlState.SelectedValue; 

One other point of note, the web service class itself must be decorated with [System.Web.Script.Services.ScriptService].

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Comments

Add comment


 

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

dotnetpete

Hi I'm dotnetpete. I'm an owner and software developer at Advantech Software in Brisbane, Australia. My passions are writing great software and coffee.