hi every1 i just upgraded from atlas to ajax 2.0
it wasnt to hard but i have a problem i used the <atlas:autocomplete
tag in atlas
but it wasnt like the other tags i cant just cahnge the atlas to asp:
cause it dosnt have it
how can i do it then?
any1 know?
plz help tnx a lot
Hi, you can easily implement auto completion in ajax using AJAX AutocompleteExtender, the sample code is shown below.
.aspx page
<asp:TextBox ID="txt_search_city" Width="130px" runat="server">
<cc1:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" TargetControlID="txt_search_city"
ServiceMethod="GetCompletionListWithContext" UseContextKey="true" MinimumPrefixLength="2"
EnableCaching="false" CompletionSetCount="20" CompletionInterval="2000" FirstRowSelected="true"
DelimiterCharacters=";," />
And in Code Behind - aspx.vb
<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()> _
Public Shared Function GetCompletionListWithContext(ByVal prefixText As String, ByVal count As Integer, ByVal contextKey As String) As String()
If Not contextKey = Nothing Then
Return "this is a total of fifteen words that will be returned when we use context".Split(" ")
End If
If count = 0 Then
count = 20
End If
Dim items As New System.Collections.Generic.List(Of String)
'get data from database
Dim _loc As New Locations
Dim str As String
Dim ds As DataSet = _loc.Load_Cities(prefixText, count)
If ds.Tables(0).Rows.Count > 0 Then
Dim i As Integer
For i = 0 To count - 1
str = ds.Tables(0).Rows(i).Item("city").ToString()
items.Add(str)
Next
End If
Return items.ToArray()
End Function
This will help you implementing auto completion in ASP.NET 2.0 using AJAX Toolkit
hi tnx for the reply
but can you maybe tell me how do i do it in c#?
and what are these two?
<System.Web.Services.WebMethod()> _
<System.Web.Script.Services.ScriptMethod()>
where do i put stuff like that?
please help
tnx
Hi,
AJAX Toolkit Autocomplete Extender use Webservice Method for fetching records and display in auto popup list, when user type some text in textbox. therefore you must create web method with same definition as describe in ajax autocomplete documentation.
If you want not to create separate webservice page, instead of it define method in normal page code behind, then you must first, import the following namespace.
using System.Web.Services;
using System.Web.Script.Services;
then in code create a method as shown below.
[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
'// rest define in another post
}
Thanks.
No comments:
Post a Comment