Resolved Ajax ToolKit 2.0

JuggaloBrotha

VB.NET Forum Moderator
Staff member
Joined
Jun 3, 2004
Messages
4,530
Location
Lansing, MI; USA
Programming Experience
10+
I have a VS2005 WebSite that works fine using the TextBox AutoComplete extender for the 2.0 Framework. Currently our shop is upgrading all of our VS 2002, 2003 and 2005 projects to VS 2008 and as part of our code standards that we now have this VS 2005 WebSite needs to become a VS 2008 WebApp (which is better in my opinion) but the thing is, I have everything working as a WebApp now in VS 2008 except the AjaxToolkit, which we still need because the client only has the 2.0 Framework so Ajax in the 3.0 and 3.5 Frameworks is out.

There are no build errors and the dll's present in the bin folder where it is in the VS 2005 project, I set a breakpoint in the webservice and when I type in the textbox, my breakpoint in the service call never gets hit so something's not wired up right and I have no idea what since it's the same code that works in VS 2005. Anyone have any experience with this? Here's my code:
VB.NET:
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="Ajax" %>

<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:TextBox runat="server" ID="ParkLocationAjaxTextBox" Width="300" CssClass="ddlist" autocomplete="off" /> 
                                    <Ajax:AutoCompleteExtender
                                            runat="server" 
                                            BehaviorID="AutoCompleteEx"
                                            ID="ParkAutoCompleteExtender" 
                                            TargetControlID="ParkLocationAjaxTextBox"
                                            ServicePath="~/AutoComplete/AutoCompletePark.asmx" 
                                            ServiceMethod="GetCompletionList"
                                            MinimumPrefixLength="1" 
                                            CompletionInterval="1000"
                                            EnableCaching="true"
                                            CompletionSetCount="20"
                                            CompletionListCssClass="autocomplete_completionListElement" 
                                            CompletionListItemCssClass="autocomplete_listItem" 
                                            CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
                                            DelimiterCharacters=";, :">
                                            <Animations>
                                                <OnShow>
                                                    <Sequence>
                                                        <%-- Make the completion list transparent and then show it --%>
                                                        <OpacityAction Opacity="0" />
                                                        <HideAction Visible="true" />
                                                        
                                                        <%--Cache the original size of the completion list the first time
                                                            the animation is played and then set it to zero --%>
                                                         <ScriptAction Script="
                                                            // Cache the size and setup the initial size
                                                            var behavior = $find('AutoCompleteEx');
                                                            if (!behavior._height) {
                                                            var target = behavior.get_completionList();
                                                            behavior._height = target.offsetHeight - 2;
                                                            target.style.height = '0px';
                                                            }" />
                            
                                                            <%-- Expand from 0px to the appropriate size while fading in --%>
                                                                <Parallel Duration=".4">
                                                                    <FadeIn />
                                                                    <Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
                                                                </Parallel> 
                                                    </Sequence>
                                                </OnShow>
                                                <OnHide>
                                                    <%-- Collapse down to 0px and fade out --%>
                                                        <Parallel Duration=".4">
                                                            <FadeOut />
                                                            <Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
                                                        </Parallel>
                                                </OnHide>
                                            </Animations>
                                    </Ajax:AutoCompleteExtender>
WebService
VB.NET:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;

namespace Dnr_Survey.AutoComplete
{
    /// <summary>
    /// Summary description for AutoCompletePark
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    //[System.Web.Script.Services.ScriptService]
    //[System.ComponentModel.ToolboxItem(false)]
    public class AutoCompletePark : System.Web.Services.WebService
    {
        private string DbConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DnrSurveyDbConnString"].ToString();

        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {
            int CountTo;
            List<string> items = new List<string>(count);
            SqlConnection DnrSurveyConnection = new SqlConnection();
            DnrSurveyConnection.ConnectionString = DbConnectionString;
            SqlCommand SelectCommand = new SqlCommand();
            try
            {
                SelectCommand.CommandText = "DnrSurvey_Sel_Locations_List";
                SelectCommand.CommandType = CommandType.StoredProcedure;

                SelectCommand.Parameters.Add("@locationName", SqlDbType.VarChar, 10);
                SelectCommand.Parameters["@locationName"].Value = prefixText;

                SelectCommand.Connection = DnrSurveyConnection;
                SqlDataAdapter myDataAdapter = new SqlDataAdapter();
                DataSet myDataSet = new DataSet();
                myDataAdapter.SelectCommand = SelectCommand;
                DnrSurveyConnection.Open();
                myDataAdapter.Fill(myDataSet);
                DataView dv = myDataSet.Tables[0].DefaultView;
                if (count > dv.Count) { CountTo = dv.Count; } else { CountTo = count; }
                for (int i = 0; i < CountTo; i++)
                {
                    items.Add(Convert.ToString(dv[i]["Location_Name"]));
                }
            }
            catch (Exception ex)
            {
                items.Add(ex.Message);
            }
            finally
            {
                DnrSurveyConnection.Close();
            }
            return items.ToArray();
        }
    }
}
 
Ok, I got it, when I used VS 2008's 'upgrade WebSite to WebApp' convertion thing, it re-wrote the entire web config and only kept the connection string from the previous web config. Once I added the ajax extension method stuff back in, it works.
 
Back
Top