Asked by:
AutoComplete Extender , Web Service Not Firing :(

Question
-
User1208695299 posted
Hi all
Here i had written code for AutoComplete... when i enter something in textbox that full row will went off...
here .aspx code<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:TemplateField HeaderText="Mode">
<ItemTemplate>
<asp:ScriptManagerProxy ID="ScriptManagerProxy3" runat="server">
<Services>
<asp:ServiceReference Path="~/WebService1.asmx" />
</Services>
</asp:ScriptManagerProxy>
<asp:TextBox ID="txtFinancialInstrumentName" runat="server" AutoPostBack="true" Text='<%# Bind("FinancialInstrumentName")%>' OnTextChanged="TxtReceipt_TextChanged" Columns="15" MaxLength="10"></asp:TextBox>
<asp:AutoCompleteExtender ID="txtFinancialInstrumentName_AutoCompleteExtender" FirstRowSelected="true" runat="server" CompletionInterval="1" CompletionSetCount="10" DelimiterCharacters="" Enabled="True" MinimumPrefixLength="1" ServiceMethod="GetFinList" ServicePath="~/WebService1.asmx" TargetControlID="txtFinancialInstrumentName" UseContextKey="True" EnableCaching="true" ViewStateMode="Enabled" >
</asp:AutoCompleteExtender>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle HorizontalAlign="Left" />
</asp:TemplateField>And my Web Service Page is WebService1.asmx
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports Rashmika.Healthcare.Library
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class WebService1
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function HelloWorld() As String
Return "Hello World"
End Function
<System.Web.Services.WebMethod> _
<System.Web.Script.Services.ScriptMethod> _
Public Shared Function GetFinList(ByVal prefixText As String) As List(Of String)
Dim List As List(Of FinancialInstrument) = Finance.FilterByName(prefixText.Trim)
Dim ReturnList As New List(Of String)
For Each FinancialInstrument In List
ReturnList.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(FinancialInstrument.Name, FinancialInstrument.Id))
Next
Return ReturnList
End Function
<System.Web.Services.WebMethod> _
<System.Web.Script.Services.ScriptMethod> _
Public Shared Function GetBankList(ByVal prefixText As String) As List(Of String)
Dim List As List(Of Bank) =Bank.FilterByName(prefixText.Trim)
Dim ReturnList As New List(Of String)
For Each Bank In List
ReturnList.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(Bank.Name, Bank.Id))
Next
Return ReturnList
End Function
End ClassWednesday, February 26, 2014 12:15 AM
All replies
-
User1140095199 posted
Hi,
Firstly Use the AjaxToolkitManger.
<ajaxToolkit:ToolkitScriptManager ID="ajt1" runat="server"> </ajaxToolkit:ToolkitScriptManager>
It is prefered to use AjaxToolScriptManager if you are using Ajax Controls.
Secondly, use proper TagPrefix:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TryOuts.Default1" %> <%@ Register tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" %>
Then use ajaxToolKit instead of asp as prefix for ajax controls:
<ajaxToolkit:AutoCompleteExtender ID="ac1" runat="server" ></ajaxToolkit:AutoCompleteExtender>
Add the Register and use proper tagPrefix.
Best Regards!Thursday, February 27, 2014 5:54 AM -
User1208695299 posted
@Sam - MSFT
No... still i have same problem... it displaying every thing in gridview(Textbox and all), but auto-complete not working and even not hitting web service also...
Wednesday, March 5, 2014 11:09 PM -
User1208695299 posted
@Sam - MSFT
If i use <ajaxToolkit:ToolkitScriptManager ID="ajt1" runat="server"> </ajaxToolkit:ToolkitScriptManager>
It showes an error like this while accessing gridview "Only one instance of a ScriptManager can be added to the page." in this code
With gvReceiptDetail
.DataSource =Receipt.OrderById
.DataKeyNames = Keys
.Visible = True
.DataBind()
End WithWednesday, March 5, 2014 11:18 PM -
User1140095199 posted
Hi,
Yes, that's right. Either use AjaxToolKitManager or ScriptManager don't use both. We can only use one script Manage in a ASP page. Since you have used Ajax controls so I suggested you to use AjaxToolKitManager.
Regards!
Thursday, March 6, 2014 11:25 PM