0

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
Ankit
  • 6,388
  • 8
  • 54
  • 79

1 Answers1

1

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.

codingbadger
  • 42,678
  • 13
  • 95
  • 110
  • 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. – Ankit Jun 25 '10 at 09:25
  • 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 !! – Ankit Jun 25 '10 at 11:33
  • 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 – codingbadger Jun 25 '10 at 11:39
  • tried both.. but neither worked i 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 :( – Ankit Jun 25 '10 at 11:46
  • Can you post your complete code? I have answered the original question - your original post doesn't mention a Modal Popup. – codingbadger Jun 25 '10 at 12:03
  • 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: – Ankit Jun 25 '10 at 13:03