Ajax AutoCompleteExtender Page Method Magic
Using AJAX AutocompleteExtender Page Methods can be a tricky proposal, as I have discovered recently while working on a project. There seems to be a few key settings that seem to be elusive. Countless searches later I have put it all together and though I would share it with with you.
Why use page methods instead of a Webservice file ASMX?? If you only have one extender and/or you want to keep everything in one file, using page methods is a quick way to do it.
Here's the quick checklist:
- Script Manager must have it's EnablePageMethods property set to true
- Page method must be marked Public and Shared
- Method must be in the aspx file and not in a user control
- Method must be marked with <webmethod> and <Scriptmethod attribute>
- Method must be declared specifically as outlined below
<WebMethod()> _ <Script.Services.ScriptMethod()> _ Public Shared Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As System.String() Return {"", ""} End Function
"A callable page method is a public static (or Shared in Visual Basic® .NET) method defined in the codebehind class and decorated with the same WebMethod attribute used for Web service methods. At present, this is limited to ASPX pages-both inline and codebehind code-but might be extended in the future to user controls and custom controls."
Mr. Esposito's article goes in depth on the usage and options available
Hope this helps someone... Happy Coding

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home