We often use Ajax controls in our projects. But simple mistakes make a project difficult.
I came across this problem by searching a lot in different forums and websites.
Now I am explaining full length of code in my blogspot.
AutoComplete is an ASP.NET AJAX extender that can be attached to any TextBox control, and will associate that control with a popup panel to display words that begin with the prefix typed into the textbox
IN ASP.NET
<form id="aspnetForm" name="aspnetForm" runat="server">
<asp:ScriptManager runat="server" />
<div class="demoarea">
<div class="demoheading">AutoComplete Control lab</div>
<p/>
Type something
:
<asp:TextBox runat="server" ID="myTextBox" Width="300" autocomplete="off" />
<AJAX:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="myTextBox" ServicePath="test.asmx" ServiceMethod="GetResults" MinimumPrefixLength="1"
CompletionInterval="1000"
EnableCaching="true"
CompletionSetCount="12" />
IN WEBSERVICE Test.vb
Imports System.Web
Imports System.Web.Services
Imports System.Web.Script.Services
Imports System.Web.Services.Protocols
Imports System.Data.SqlClient
Imports System.Data
Imports System.Collections.Generic
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Inherits System.Web.Services.WebService
<WebMethod(EnableSession:=True)> _
Public Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()
Dim ds As New DataSet
Dim pre
Dim i As Integer
ds = Session("dsStyle")
If ds.Tables(0).Rows.Count <> 0 Then
Dim items As New List(Of String)
For i = 0 To ds.Tables(0).Rows.Count - 1
pre = ds.Tables(0).Rows(i).Item("matinfo")
If prefixText.ToLower = pre.Substring(0, prefixText.Length).ToLower Or prefixText.ToUpper = pre.Substring(0, prefixText.Length).ToUpper Then
items.Add(ds.Tables(0).Rows(i).Item("matinfo").ToString())
End If
Next
Return items.ToArray
End If
Here in this webservice,i got a data in dataset from sessions .To activate sessions in Webservice we have to include EnableSession:=True as mentioned above.Please let me know if there are any queries.
Thanks.
Monday, October 20, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment