SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 211 | Next

Robin Pars, Laurence Moroney, and John Grieb

"Foundations of ASP.NET AJAX"

NET AJAX CONTROL TOOLKIT (PART 1) 145
The name of the method of course can be different from what is listed here, but the
parameters and return types much match that exactly, or the AutoCompleteExtender will
not work properly. With that in mind, create a new .asmx page and use the following code
to create the main web method:
[WebMethod]
public string[] GetSuggestedStrings(string prefixText, int count)
{
//Default to 3 if the count is zero
if (count == 0)
count = 3;
List stringList = new List(count);
for (int i = 0; i < count; i++)
{
stringList.Add(prefixText + i.ToString());
}
return stringList.ToArray();
}
This simple web method returns at least three suggested strings that, for the purposes
of this sample, are simply the prefix with the index number of the list array. In most
practical cases, you want to use more complex logic for suggestions of value, but you
must be careful about performing very long and resource-intensive operations here. If
you are planning to make database calls with intricate queries, make sure you have done
ample testing to ensure its feasibility because the suggestions are useless if they take a
long time to return.


Pages:
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223