Error: AjaxControlToolkit.AutoCompleteExtender missing required ServiceMethod property value for txtSearch_AutoCompleteExtender

micah
 
on Sep 12, 2016 02:18 AM
8138 Views

 

Server Error in '/' Application.
AjaxControlToolkit.AutoCompleteExtender missing required ServiceMethod property value for txtSearch_AutoCompleteExtender.
Parameter name: ServiceMethod
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: AjaxControlToolkit.AutoCompleteExtender missing required ServiceMethod property value for txtSearch_AutoCompleteExtender.
Parameter name: ServiceMethod

Source Error:


Line 6:               source: function (request, response) {
Line 7:                   $.ajax({
Line 8:                       url: '<%=ResolveUrl("~/Timeline.aspx/GetNames") %>',
Line 9:                           data: "{ 'prefix': '" + request.term + "'}",
Line 10:                          dataType: "json",

 

Download FREE API for Word, Excel and PDF in ASP.Net: Download
Results 1 - 5 of 8
dharmendr
 
on Sep 12, 2016 02:23 AM
on Sep 15, 2016 02:33 AM

Hi micah,

Check you didn't assign WebMethod attribute to the method in code behind. Your code should be like below.

[System.Web.Services.WebMethod]
public static string[] GetNames(string prefix)
{
}

Also You need to assign the ServiceMethod to the AutoCompleteExtender.

micah
 
on Sep 12, 2016 02:46 AM

i did but still getting error

 

[WebMethod]
    public static string[] GetNames(string prefix)
    {
        List<string> users = new List<string>();
        using (SqlConnection conn = new SqlConnection())
        {
            conn.ConnectionString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
            using (SqlCommand cmd = new SqlCommand())
            {
                cmd.CommandText = "select Name from User3 where " + "Id like @SearchText + '%'";
                cmd.Parameters.AddWithValue("@SearchText", prefix);
                cmd.Connection = conn;
                conn.Open();
                using (SqlDataReader sdr = cmd.ExecuteReader())
                {
                    while (sdr.Read())
                    {
                        users.Add(string.Format("{0}-{1}", sdr["Name"], sdr["Id"]));
                    }
                }
                conn.Close();
            }
        }
        return users.ToArray();

error

 

Server Error in '/' Application.
AjaxControlToolkit.AutoCompleteExtender missing required ServiceMethod property value for txtSearch_AutoCompleteExtender.
Parameter name: ServiceMethod
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentException: AjaxControlToolkit.AutoCompleteExtender missing required ServiceMethod property value for txtSearch_AutoCompleteExtender.
Parameter name: ServiceMethod

Source Error:


Line 6:               source: function (request, response) {
Line 7:                   $.ajax({
Line 8:                       url: '<%=ResolveUrl("~/Timeline.aspx/GetNames") %>',
Line 9:                           data: "{ 'prefix': '" + request.term + "'}",
Line 10:                          dataType: "json",

 

dharmendr
 
on Sep 12, 2016 02:53 AM

Share the html.

micah
 
on Sep 12, 2016 05:54 AM

html markups

 

 <div class="input-group" style="">
                                   <asp:ScriptManager ID="ScriptManager" runat="server" EnablePageMethods = "true">  
  
    </asp:ScriptManager>  
                                  
                                 
                                   <asp:TextBox ID="txtSearch" runat="server" class="form-control" placeholder="Search..."
                Width="100%"/>


      <asp:AutoCompleteExtender runat="server" ServicePath="" DelimiterCharacters="" Enabled="True" TargetControlID="txtSearch" ID="txtSearch_AutoCompleteExtender"></asp:AutoCompleteExtender>
      <asp:HiddenField ID="hfUserName" runat="server" />
                                   <span class="input-group-btn">
                                   <asp:LinkButton ID="btnSearch" runat="server" class="btn btn-twitter"   OnClick="btnSearch_Click" EnableViewState="false" CausesValidation="false"> 
                                       <i class="fa fa-search"></i>

                                   </asp:LinkButton>
                                   </span>
                               </div>

 

dharmendr
 
on Sep 12, 2016 06:12 AM

Change like this.

<asp:AutoCompleteExtender runat="server" ServiceMethod="GetNames" DelimiterCharacters="" Enabled="True" TargetControlID="txtSearch" ID="txtSearch_AutoCompleteExtender"></asp:AutoCompleteExtender>

 

Results 1 - 5 of 8