I am trying to put Ajax Autocomplete extender method in my child page using page method.Somehow page method is not firing up and instead page holds for a second saying long script is executing and shows some random page mark up in targeted textbox.
I tried setting context key parameter but it didn't work. I even set my code behind file path in sevicepath attribute of extender but that too didn't work
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
CodeBehind="FleetBooking.aspx.cs" Inherits="TMSAdmin.FleetBooking" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
TagPrefix="CC1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<head runat="server"></head>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" >
</asp:ScriptManager>
<section class="content-header">
<h1>Fleet booking
<small>Preview page</small>
</h1>
</section>
<div class="row">
<div class="col-md-2">
<h4>Route Name:</h4>
</div>
<div class="col-md-2">
<asp:TextBox ID="txtRoutes" runat="server" CssClass="form-control" />
<CC1:AutoCompleteExtender ServiceMethod="GetRoutes" MinimumPrefixLength="1"
CompletionInterval="100"
EnableCaching="false" CompletionSetCount="10"
TargetControlID="txtRoutes"
ID="AutoCompleteExtender2"
runat="server" FirstRowSelected="false"
CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem">
</CC1:AutoCompleteExtender>
</div>
</asp:Content>
Code behind:
[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static List<string> GetRoutes(string prefixText, int count)
{
using (SqlConnection con = new SqlConnection())
{
//con.ConnectionString = ConfigurationManager.ConnectionStrings["Conn"].ConnectionString;
con.ConnectionString = ClsCon.myconn;
using (SqlCommand com = new SqlCommand())
{
com.CommandText = "select Route_Name from tbl_RouteMaster where "
+ "Route_Name like ' @Search + '%'";
com.Parameters.AddWithValue("@Search", prefixText);
com.Connection = con;
con.Open();
List<string> routeNames = new List<string>();
using (SqlDataReader sdr = com.ExecuteReader())
{
while (sdr.Read())
{
routeNames.Add(sdr["Route_Name"].ToString());
}
}
con.Close();
return routeNames;
}
}
}
I expect it should fire my page method so that i can debug and solve issues if any.