<?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>Ajax Updates &#187; search autocomplete</title>
	<atom:link href="http://www.ajaxupdates.com/tag/search-autocomplete/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ajaxupdates.com</link>
	<description>Latest Ajax Scripts, Examples, News and other Ajax related stuff</description>
	<lastBuildDate>Fri, 12 Feb 2010 12:46:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Search Autocomplete with .NET</title>
		<link>http://www.ajaxupdates.com/search-autocomplete-with-net/</link>
		<comments>http://www.ajaxupdates.com/search-autocomplete-with-net/#comments</comments>
		<pubDate>Thu, 02 Jul 2009 14:53:40 +0000</pubDate>
		<dc:creator>alyaspk</dc:creator>
				<category><![CDATA[Ajax Scripts]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.net autocomeplte]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[dot net]]></category>
		<category><![CDATA[dotnet]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[search auto complete]]></category>
		<category><![CDATA[search autocomplete]]></category>
		<category><![CDATA[view auto complete]]></category>

		<guid isPermaLink="false">http://www.ajaxupdates.com/?p=2028</guid>
		<description><![CDATA[I am working on a rich content app for one of my talks at TechEd Europe and I thought it would be a good idea to implement a search box with an autocomplete of the past search quires. The intuition here is that the changes are someone else has searched for the same thing you [...]


Related Listings:<ol><li><a href='http://www.ajaxupdates.com/autocomplete-widget/' rel='bookmark' title='Permanent Link: Autocomplete Widget'>Autocomplete Widget</a> <small>The tool is designed to bring good feelings for both...</small></li>
<li><a href='http://www.ajaxupdates.com/fancy-apple-com-style-search-suggestion/' rel='bookmark' title='Permanent Link: Fancy Apple.com Style Search Suggestion'>Fancy Apple.com Style Search Suggestion</a> <small>Apple is known to create beautiful products (next to the...</small></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>I am working on a rich content app for one of my talks at TechEd Europe and I thought it would be a good idea to implement a search box with an autocomplete of the past search quires. The intuition here is that the changes are someone else has searched for the same thing you are searching for, so past queries is an interesting set of options to offer. Not to mention it is fun to look at what other people are searching for <img src='http://www.ajaxupdates.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  What I think is cool about this is I was able to implement it with less than 10 lines of code and absolutely no database specific logic. I did this with a combination of the ASP.NET 2.0 profile store and the ASP.NET AJAX AutoCompleteExtender…</p>
<p>Here is an example screenshot and all the code\markup required… I&#8217;d love to hear what you think… do you think this makes for a compelling demo?</p>
<p><img src="http://blogs.msdn.com/brada/attachment/886765.ashx" alt="" /></p>
<p>Html for search box and &#8220;submit&#8221; link (default.aspx)</p>
<pre class="brush: html">&lt;div id=&quot;links&quot;&gt;
   Search for
   &lt;asp :TextBox ID=&quot;searchtext&quot; runat=&quot;server&quot; CssClass=&quot;searchbox&quot; &gt;&lt;/asp&gt; 
   &lt;asp :LinkButton ID=&quot;LinkButton1&quot; runat=&quot;server&quot; OnClick=&quot;LinkButton1_Click&quot;&gt;go&lt;/asp&gt;&lt;br /&gt;
&lt;/div&gt;
</pre>
<p>ASP.NET handler for the LinkButton (default.aspx)</p>
<pre class="brush: javascript">protected void LinkButton1_Click(object sender, EventArgs e)
{
   StringCollection list = Profile.SearchTerms;
   if (!list.Contains(searchtext.Text))
   {
      list.Add(searchtext.Text);
   }
   //TODO: Do search
}
</pre>
<p>ASP.NET AJAX goodness (default.aspx)</p>
<pre class="brush: javascript">
&lt;asp :ScriptManager ID=&quot;ScriptManager&quot; runat=&quot;server&quot; /&gt;
&lt;asp :AutoCompleteExtender ID=&quot;AutoCompleteExtender1&quot; TargetControlID=&quot;searchtext&quot;
                          runat=&quot;server&quot; ServiceMethod=&quot;GetCompletionList&quot;
                          ServicePath=&quot;~/SearchAutoComplete.asmx&quot; MinimumPrefixLength=&quot;1&quot; /&gt;
</pre>
<p>Web Service Implementation (SearchAutoComplete.asmx)</p>
<pre class="brush: javascript">
[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
   StringCollection list = (StringCollection)HttpContext.Current.Profile[&quot;SearchTerms&quot;];
   List&lt;string&gt; suggestions = new List&lt;/string&gt;&lt;string&gt;();
   foreach (string s in list)
   {
      if (s.StartsWith(prefixText))
      {
         suggestions.Add(s);
      }
   }
   return suggestions.ToArray();
}
&lt;/string&gt;</pre>
<p>Profile Config Section – (Web.config in <system .web> )</p>
<pre class="brush: html">
&lt;profile&gt;
   &lt;properties&gt;
      &lt;add name=&quot;SearchTerms&quot;
           type=&quot;System.Collections.Specialized.StringCollection&quot;
           serializeAs=&quot;Xml&quot; /&gt;
    &lt;/properties&gt;
&lt;/profile&gt;
</pre>
<p>Exercises left for the user</p>
<p>    * Clean up any bad or misleading search terms<br />
    * Sort hits by relevance<br />
    * Add a hit count<br />
    * Age out older results<br />
Demo: http://www.google.com<br />
Source: <a href="http://blogs.msdn.com/brada/archive/2006/10/27/search-autocomplete-with-asp-net-ajax-extensions.aspx">http://blogs.msdn.com/brada/archive/2006/10/27/search-autocomplete-with-asp-net-ajax-extensions.aspx</a></system></p>
<div id="st0000000001" class="st-taf"><script src="http://taf.socialtwist.com:80/taf/js/shoppr.core.js?id=0000000001"></script><img style="border:0;margin:0;padding:0;" src="http://tellafriend.socialtwist.com:80/wizard/images/tafbutton_blue16.png" onmouseout="hideHoverMap(this)" onmouseover="showHoverMap(this, '0000000001', 'http%3A%2F%2Fwww.ajaxupdates.com%2Fsearch-autocomplete-with-net%2F', 'Search+Autocomplete+with+.NET')" onclick="cw(this, {id:'0000000001',link: 'http%3A%2F%2Fwww.ajaxupdates.com%2Fsearch-autocomplete-with-net%2F', title: '+Search+Autocomplete+with+.NET+' })"/></div>

<p>Related Listings:<ol><li><a href='http://www.ajaxupdates.com/autocomplete-widget/' rel='bookmark' title='Permanent Link: Autocomplete Widget'>Autocomplete Widget</a> <small>The tool is designed to bring good feelings for both...</small></li>
<li><a href='http://www.ajaxupdates.com/fancy-apple-com-style-search-suggestion/' rel='bookmark' title='Permanent Link: Fancy Apple.com Style Search Suggestion'>Fancy Apple.com Style Search Suggestion</a> <small>Apple is known to create beautiful products (next to the...</small></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.ajaxupdates.com/search-autocomplete-with-net/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->