views:

44

answers:

1

Hi,

following is the code i am using and it is not working.

<asp:TextBox ID="txtWarrantNumber" runat="server"></asp:TextBox>
<AjaxCtrl:AutoCompleteExtender ID="acWarrantNumber" runat="server" TargetControlID="txtWarrantNumber"
    ServiceMethod="GetWarrantNumber" ShowOnlyCurrentWordInCompletionListItem="true"
    CompletionInterval="100" EnableCaching="true" MinimumPrefixLength="1" CompletionSetCount="4">
</AjaxCtrl:AutoCompleteExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
</PopupTemplate>

Public Shared Function GetWarrantNumber(ByVal prefixText As String, ByVal count As Integer) As String()
    Dim warrantNumbers() As String = {"ankit", "sachin", "ankrrr", "ankppp"}
    Return warrantNumbers
End Function
+1  A: 

The function GetWarrantNumber needs to be in a WebService as a WebMethod. And you need to provide the location of the WebService.asmx file in the ServicePath property.

AutoCompleteExtender

To do this without a webservice you need wrap your method with the following within the Page:

<script runat="server">
    <System.Web.Services.WebMethod()> _
    <System.Web.Script.Services.ScriptMethod()> _
  Public Shared Function GetWarrantNumber()
  .....
  End Function
</script>

If you do it this way then you don't need to provide a ServicePath.

Barry
Hi, Thanks for the reply. But i dont wanna use web services and read that the autocomplete can be used without webservices also using page functions. thus i declared a static function on the page.
I have updated my answer
Barry
thanks for the reply. This worked for me on a test page but i am using AjaxControlToolkit.ModalPopupExtender and the textbox is not working on that. Any idea !!
The Auto Complete list will display behind the Modal Popup. See this link for a simple Javascript fix http://codingresource.blogspot.com/2010/03/autocompleteextender-problems-with.html or here for more complete solution using CSS http://forums.asp.net/p/1369112/2863865.aspx#2863865
Barry
tried both.. but neither workedi set the textbox AutoCompleteType="Disabled" but still its showing the autocomplete items and not able to show the actual autocomplete list from server. I attached the process and checked if its hitting the server while typing in the textbox and found that its not hitting the serverside method :(
Can you post your complete code? I have answered the original question - your original post doesn't mention a Modal Popup.
Barry
thanks for that.. i have marked the q as answered.there is a AjaxControlToolkit.ModalPopupExtender in which there is an update panel in which following is the code: