<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Joel Hainley &#187; AJAX</title>
	<atom:link href="http://www.joelhainley.com/index.php/tag/ajax/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.joelhainley.com</link>
	<description>my thoughts and adventures</description>
	<lastBuildDate>Mon, 19 Dec 2011 19:34:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ASP.NET AJAX AutoCompleteExtender not working</title>
		<link>http://www.joelhainley.com/index.php/2010/01/19/asp-net-ajax-autocompleteextender-not-working/</link>
		<comments>http://www.joelhainley.com/index.php/2010/01/19/asp-net-ajax-autocompleteextender-not-working/#comments</comments>
		<pubDate>Tue, 19 Jan 2010 15:19:01 +0000</pubDate>
		<dc:creator>joelhainley</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[ASP.NET AJAX]]></category>
		<category><![CDATA[AutoCompleteExtender]]></category>

		<guid isPermaLink="false">http://www.joelhainley.com/?p=239</guid>
		<description><![CDATA[I was working on some new features for a client recently and they had a need for an AutoCompleteExtender on one of their forms. I hadn&#8217;t used the AutoCompleteExtender yet so I read through the documentation, coded up a webservice, and added  the appropriate items to the page and ran the app. When I tried [...]]]></description>
			<content:encoded><![CDATA[<p>I was working on some new features for a client recently and they had a need for an AutoCompleteExtender on one of their forms. I hadn&#8217;t used the AutoCompleteExtender yet so I read through the documentation, coded up a webservice, and added  the appropriate items to the page and ran the app. When I tried typing into the TextBox that the AutoCompleteExtender was pointed at, nothing happened. In this posting I will detail the things that I looked at, and try to put together an accurate guide to making sure you&#8217;re AutoComplete works. I tried some of the &#8220;tips&#8221; that are out there after I had things working and they don&#8217;t help. So hopefully this will be a bit more definitive and useful than what I came across.</p>
<p>The first thing that I looked at was the method signature of the webservice. The <a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx"title="Documentation"  onclick="javascript:pageTracker._trackPageview('/outbound/article/www.asp.net');">documentation</a> indicates that you need to use one of the following method signatures :</p>
<div class="codesnip-container" >public string[] GetCompletionList(string prefixText, int count) { &#8230; }</div>
<p>..OR..</p>
<div class="codesnip-container" >public string[] GetCompletionList(    string prefixText, int count, string contextKey) { &#8230; }</div>
<p>What the documentation doesn&#8217;t tell you is that the name/spelling/capitalization of the method signature must match EXACTLY. If you decide that you don&#8217;t like the camelcase on the prefixText and want to use prefixtext instead&#8230;.IT WON&#8217;T WORK. So make sure you have those signature matching correctly. I have seen some indications on the internet that you should use a static method such as :</p>
<div class="codesnip-container" >public static string[] GetCompletionList(string prefixText, int count) { &#8230; } // !!! DON&#8221;T DO THIS !!!</div>
<p>DON&#8217;T DO THIS. It doesn&#8217;t work. Only the exact methods defined in the documentation and shown above will work. </p>
<p>Back to my project, I get these methods defined properly, compile the project, go to my textbox start to type and still I get NOTHING. So I look over the documentation and see some information about the class/method attributes that must be added. The documentation shows the following :</p>
<div class="codesnip-container" >[System.Web.Services.WebMethod]<br />
[System.Web.Script.Services.ScriptMethod]<br />
public string[] GetCompletionList(<br />
    string prefixText, int count) { &#8230; }</div>
<p>What they don&#8217;t show in the documentation is that you need to also add the following to the class definition</p>
<div class="codesnip-container" >[System.Web.Script.Services.ScriptService]</div>
<p>So I make these changes and run the application again, and STILL it doesn&#8217;t work. I&#8217;m stumped. I put a break at the webservice method and run again and it&#8217;s not even hitting the webservice. After a little bit of digging I come across <a href="http://www.asp.net/AJAX/Documentation/Live/ConfiguringASPNETAJAX.aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/www.asp.net');">Adding ASP.NET AJAX Configuration Elements to an Existing Web Site</a> and a lightbulb goes on. This project was not setup as an AJAX.NET site, in fact it predates ASP.NET AJAX by a couple of years. Sure enough as I start to dig through the documentation I notice mappings to handlers for the webservice calls. So I follow the changes specified and run the site and it worked!</p>
<p>It took me a while to get this figured out, and I suspect there might be a few others out there that might have some problems getting this working. Below is a complete class that you can use as a reference. I haven&#8217;t included any of the code defining the AutoCompleteExtender because the documentation seems sufficient and I didn&#8217;t have any problems. There is also a video on the ASP.NET AJAX site that walks you through configuring your first AutoCompleteExtender and does a good job, as long as your site is configured properly!</p>
<p>Good luck!</p>
<div class="codesnip-container" >using System;<br />
using System.Collections;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Web;<br />
using System.Web.Services;<br />
using System.Web.Services.Protocols;<br />
using System.Web.Script.Services;<br />
using DALInterface;<br />
using CGWeb.framework;</p>
<p>namespace CGWeb.webservices {<br />
    /// <summary><br />
    /// Summary description for NewDXCompletion<br />
    /// </summary><br />
    /// </p>
<p>    [WebService(Namespace = "http://tempuri.org/")]<br />
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]<br />
    [ToolboxItem(false)]<br />
    [System.Web.Script.Services.ScriptService]<br />
    public class NewDXCompletion : System.Web.Services.WebService {</p>
<p>        [System.Web.Services.WebMethod]<br />
        [System.Web.Script.Services.ScriptMethod]<br />
        public string[] GetCompletionList(string prefixText, int count) { &#8230; }<br />
    }<br />
}</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.joelhainley.com/index.php/2010/01/19/asp-net-ajax-autocompleteextender-not-working/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

