M
Michael Appelmans
I have essentially copied the samplelist2.aspx from the Atlas samples but
the autocomplete feature is not working in my page. The web service asmx
works from a browser. Thanks for any suggestions on how to diagnose this.
Here is my aspx code:
<atlas:ScriptManager ID="scriptmanager1" EnablePartialRendering="true"
runat="Server" />
<aspanel ID="Panel1" runat="server" style="margin-top:10px;padding-left:20px;"
Height="24px" Width="640px">
<atlas:UpdatePanel ID="UpdatePanel1" Mode="Conditional" runat="server">
<ContentTemplate>
<asp:Label ID="ShowLabel" runat="server" CssClass="waLabel">Show:
</asp:Label>
<aspropDownList ID="SearchModeDropDownList" runat="server"
AutoPostBack="True" CssClass="waDdl">
<asp:ListItem Selected="True" Value="0">All</asp:ListItem>
<asp:ListItem Value="1">Search</asp:ListItem>
</aspropDownList>
<asp:TextBox ID="SearchLocationNameTextBox" runat="server" CssClass="waTextBox"></asp:TextBox>
<asp:Button ID="SearchBtn" CssClass="waButton" Text=" >> "
CommandName="search" CommandArgument="-2" runat="server" />
</ContentTemplate>
</atlas:UpdatePanel>
</aspanel>
<atlas:AutoCompleteExtender ID="AutoCompleteSearch" runat="server">
<atlas:AutoCompleteProperties TargetControlID="SearchLocationNameTextBox"
Enabled="true" ServicePath="VanPoolService.asmx"
ServiceMethod="GetLocationNames" MinimumPrefixLength="1"/>
</atlas:AutoCompleteExtender>
Here is my web service code:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class VanPoolService : System.Web.Services.WebService
{
public VanPoolService()
{
}
[WebMethod]
public string[] GetLocationNames(string prefixText, int count)
{
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cobbcc"].ConnectionString);
SqlCommand cmd = new SqlCommand(
"SELECT DISTINCT TOP(@nrows) Name FROM Locations WHERE Name like
@term", cn);
cmd.Parameters.Add("nrows", count);
cmd.Parameters.Add("term", prefixText + "%");
List<string> suggestions = new List<string>();
cn.Open();
using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
while (dr.Read())
suggestions.Add(dr[0].ToString());
}
return suggestions.ToArray();
}
}
the autocomplete feature is not working in my page. The web service asmx
works from a browser. Thanks for any suggestions on how to diagnose this.
Here is my aspx code:
<atlas:ScriptManager ID="scriptmanager1" EnablePartialRendering="true"
runat="Server" />
<aspanel ID="Panel1" runat="server" style="margin-top:10px;padding-left:20px;"
Height="24px" Width="640px">
<atlas:UpdatePanel ID="UpdatePanel1" Mode="Conditional" runat="server">
<ContentTemplate>
<asp:Label ID="ShowLabel" runat="server" CssClass="waLabel">Show:
</asp:Label>
<aspropDownList ID="SearchModeDropDownList" runat="server"
AutoPostBack="True" CssClass="waDdl">
<asp:ListItem Selected="True" Value="0">All</asp:ListItem>
<asp:ListItem Value="1">Search</asp:ListItem>
</aspropDownList>
<asp:TextBox ID="SearchLocationNameTextBox" runat="server" CssClass="waTextBox"></asp:TextBox>
<asp:Button ID="SearchBtn" CssClass="waButton" Text=" >> "
CommandName="search" CommandArgument="-2" runat="server" />
</ContentTemplate>
</atlas:UpdatePanel>
</aspanel>
<atlas:AutoCompleteExtender ID="AutoCompleteSearch" runat="server">
<atlas:AutoCompleteProperties TargetControlID="SearchLocationNameTextBox"
Enabled="true" ServicePath="VanPoolService.asmx"
ServiceMethod="GetLocationNames" MinimumPrefixLength="1"/>
</atlas:AutoCompleteExtender>
Here is my web service code:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class VanPoolService : System.Web.Services.WebService
{
public VanPoolService()
{
}
[WebMethod]
public string[] GetLocationNames(string prefixText, int count)
{
SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["cobbcc"].ConnectionString);
SqlCommand cmd = new SqlCommand(
"SELECT DISTINCT TOP(@nrows) Name FROM Locations WHERE Name like
@term", cn);
cmd.Parameters.Add("nrows", count);
cmd.Parameters.Add("term", prefixText + "%");
List<string> suggestions = new List<string>();
cn.Open();
using (SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
{
while (dr.Read())
suggestions.Add(dr[0].ToString());
}
return suggestions.ToArray();
}
}