A ScriptAculoUs autocomplete web control

To the reader - this post has evolved much and contains many comments. You don't need to read through them all to find things which have been forgotten or to find bug fixes and new features, because each of them, if valuable, has already been included in the release version of the code.

To contributors and readers - please don't use this post' comments anymore for anything related to the project, since it has now a dedicated page on the SVN hosting offered by Sourceforge, where you can submit issues, patches, ask questions and so on. All info can be found into this other blog post I dedicated to the topic.

UPDATE 24/08/06
: Added some features and fixed some bugs, thank to Laurentiu Macovei, details in the post.
UPDATE 19/08/06: Removed property AdditionalControl and added property Parameters, details in the post.
UPDATE 29/07/06: Added a new boolean property, CacheSuggestions, which lets you choose whether to cache the suggestions on the client or not. Details in the post.
UPDATE 29/07/06: Now the controls work in conjunction with Atlas, read the post for the details.
UPDATE 08/07/06: Fixed a bug affecting the control when placed inside another WebControl.
UPDATE 05/07/06: Added a property - ScrollSize - which allows to show the results in a scrolled fashion.
UPDATE 27/06/06: Now it can be embedded into a UserControl and can retrieve the values from a UserControl method.
UPDATE 24/06/06: Fixed the bug affecting Firefox and published sources.

ScriptAculoUs is a top quality JavaScript library, useful for everything related to client-side web programming, like effects, DOM programming, events and so on.
Recently they included a new "control" in the package, which is able to extend a normal HTML input text into an autocomplete control. Does this remind you of the Atlas autocomplete extender? Read on...
The word "control" is not the same as the one ASP.NET programmers are used to hear, since it now refers to a client-side behavior, which happens completely on the client.
This autocomplete control, whom you can see examples here, is very rich in features but not very developer-friendly from an ASP.NET developer point of view, because almost everything has to be programmed in the markup code and manually, so I decided to create a custom control to wrap all those functionalities in a simple to use component called ScriptAculoUs.Net.

But why is this better than the other thousand autocomplete controls available out there?
Well, first let me make a brief list of the ones I like most:
  • Atlas Autocomplete extender: very cool, but you need a webservice to retrieve results.
  • UPDATE 17/06/06: Atlas Smart Autocompletion: a textbox built on top of Atlas framework which incorporates the Atlas autocomplete extender into a reusable web control, and enhances it by allowing to retrieve the suggestion list from a page method other than the classic web service method.
  • Wilco Bauer's SmartTextBox: very well written webcontrol, source code is a must-see, but lacks client-side support.
  • AspItalia TextBox Autocomplete: a must see too, can retrieve results from a DataSource control!

Ok, these are the coolest out there. My control can be better because:

  • ScriptAculoUs is a client-side library, has great support for visual effects and the visual result is better than all of them;
  • ScriptAculoUs is cross-browser, they mostly aren't;
  • ScriptAculoUs is a continuous work in progress, it will improve and I won't have to care about it unless they change the API.

To sum it up, this is better because ScriptAculoUs preserves me from caring about the client-side programming, which is the most part in an autocomplete pattern, and provides us with a cool user interface made of fadings and scrollings (and well, much more).

Features and Usage

  • No need for a web service or an external page to retrieve the suggestions, just a page method, which has to be public, return an object implementing the IEnumerable interface and accept a string as input parameter (the typed keys) and/or a second array of strings parameter which contains the values of the controls specified within the property Parameters. Here is an example of how to write the method which returns the suggestions:
    public string[] GetSuggestion(string key)
    return new string[] { key + "aaa", key + "bbb", key + "ccc"};
    In case the property Parameters contains values, the method will require a second parameter of type string[]:
    public string[] GetSuggestion(string key, string[] parameters)
    int i = parameters.Length;
    return new string[] { key + parameters[0] + "aa", key + parameters[i-1] + "bb" };
    and the markup of the page will look like the code below (the following result can be easilly achieved by using the Visual Studio designer and utilizing its straighforward collection editor):
    <asp:TextBox id="TextBox1" runat="server"></asp:TextBox> 

    <ScriptAculoUs:AutocompleteTextBox id="AutocompleteTextBox1"
    runat="server" methodname="GetSuggestions">
    <ScriptAculoUs:TextControlParameter ControlID="TextBox1">
  • The support for effects, key navigation and everything related to client-side behaviors is great thanks to script.aculo.us.
  • The results are cached on the client by default, so that when you type again the same characters they are retrieved by the local cache instead of performing a request to the server. Caching can be disabled using the property CacheSuggestions.
  • Can be easilly configured to show an animated image next to it just using a simple property. The image shows up when the control is retrieving the results from the server and hides when the operation is complete.
  • Can be extended to use an AutocompleteProgress control, also shipped, which can be placed anywhere on the page and customized using templates, which makes its content visible when the main control is retrieving results and makes them invisible when the callback is complete. For those using Atlas, this is the same as the UpdateProgress control.
  • You can choose how many chars are needed to be typed before the control performs a callback to the server. The default value is 1.
  • The list of results appearance can be customized using some style properties called Suggestionxxx and SelectedSuggestionxxx. Easy to use.
  • It is possible to scroll through the results using the ScrollSize property. It sets the height in pixels of the suggestion list area.
  • UPDATE 29/07/06: The controls now do WORK in conjunction with the Atlas framework. In this post, Steve Marx describes his discovery of how Atlas and ScriptAculoUs can work together when the ScriptAculoUs scripts are injected in the page AFTER the Atlas scripts. Don't ask me why!
    Since I inject the scripts programmatically in the control code (I use to do it in the PreRender phase), I have not much freedom on that, but Reflectoring the Atlas ScriptManager control I found that it injects its script during the Page PreRenderComplete event. Thus the problem turns out to be how to inject them LATER than Atlas.
    As far as I know there is no event which fires after that one in which you can safely inject something in the page, so I subscribed to that event too and I did my injections there. Of course, since both Atlas and my controls inject their scripts at the same time, it becomes important the order they assume in the page. Ok, the solution is that you'll have to place your Atlas ScriptManager control BEFORE any ScriptAculoUs.Net controls, and everything will work fine! That won't be an issue I guess, since usually the ScriptManager control is placed by default on the top of the page, before any other controls.
    I even played around with it a bit, and have been able to extend my AutoCompleteTextBox with the Atlas Control Toolkit's TextBoxWaterMarkExtender. Simply great.
  • UPDATE 19/08/06: Removed property AdditionalControl and added property Parameters. The only difference is that the Parameters property accepts a collection of values instead of only one. You can choose among the controls of the page which implement the ITextControl interface, that is, that can contain a text value. Those values are then passed to the method set with the property MethodName.
    If one or more values are set in the Parameters property, then the method signature which returns the suggestion list must accept a second parameter of type string[].
  • UPDATE 24/08/06: Laurentiu Macovei submitted a great contribution, here are the details:

    Features added
    • AutoCompleteAsHint property: for example you want to make a search form, but you don't know what to type to get some results. This feature actually returns a set of letters who are possible at a moment.
      Eg. These are the simplified keywords in DB: City, Police, Design, Magician and Motorcycle
      If you will type i, it will suggest you a, c, g and t. You pick one from the list, eg. c and then it will suggest you c and e. And so on. Basically when this feature is enabled, the suggestion is concatenated to the text, instead of replacing the text with it.
    • Ability to play with page_up, page_down, home, and end keys.
    • Auto-suggest when click into the textbox.
Bugs fixed
    • Annoying click on scroll (was closing the list)
    • Annoying scroll into view (it didn't work, or work bad)
    • Some wierd behaviour was fixed.
    • Big scroll size, when not needed (now the list size adapts itself to how much it needs, as maximum as you specifiy in the ScrollSize attribute. If not needed, the scroll is not displayed).

I welcome any feedback and suggestion to improve it. A screencast about how to set it up is available too. Please watch it at double speed since it was recorded on a slow virtual machine, otherwise you risk to fall asleep :-)


Binaries: no more binaries, at the moment, too hard to keep track of them, please download the source.
Sources: only available on the SVN repository, read here for details.
Screencast: ScriptAculoUs.Net Demo.wmv

kick it on DotNetKicks.com

Published 03 July 2006 11:13 PM by simoneb
Filed under: , ,


# DotNetKicks.com said on 14 July, 2006 06:51 PM
You've been kicked (a good thing) - Trackback from DotNetKicks.com
# Tom said on 16 August, 2006 05:18 AM
Is there any possibility to use Session object in GetSuggestion function? How to do this?
# simoneb said on 16 August, 2006 07:56 AM
Tom, as for the current implementation it's not possible to use the Session object because the page doesn't got through the pipeline but is instantiated via reflection, thus all the modules of the pipeline are not processed. This is a lightweight implementation, for such a feature you should consider one of the other autocomplete options available out there.
# softer said on 17 August, 2006 11:25 AM
The scrolling feature is really annoying, because when you try to scroll down, it will close the list :(
Also it is annoying, because when you have too little items, a big div will be displayed instead of trunking it as it needs.
# simoneb said on 17 August, 2006 12:21 PM
I know about this issue, feel free to submit a patch.
# Ozman said on 21 August, 2006 05:29 PM
Simone great tool , thanks for great work.

I had problems with this in a web control so I changed the following line in the suggestion handler to.
object instance = assembly.CreateInstance(typeName);

It now allows me to use it in a web control.

Is thier a way to check if it is a page object or a web control if it is a page use

Page instance = CreatePageInstance(type);

else web control use

object instance = assembly.CreateInstance(typeName);
# simoneb said on 21 August, 2006 08:30 PM
Hi Ozman, I must be dumb! I had already considered that situation and made it work, but in the latest release I forgot about this option and changed the code again to work only with Page objects. I'll fix it in a couple of minutes. The working principle I chose to give it is that when placed inside a page, the control looks for the method which returns the suggestions in the code behind of the page, and when placed inside a user control it searches the method in the code behind of the user control. I thought it should work in most cases. Let me know if you're exeriencing issues anymore.
# Ozman said on 21 August, 2006 10:42 PM
Once again thanks.

Your tool saved me alot of time.Hopefully I can give back to the dot net community some day. Take care..

# simoneb said on 22 August, 2006 05:17 AM
You're welcome Ozman. If you want to give something back to the community there are many ways you can do it. Personally, since I don't have much cash I can invest on this, I prefer doing that by submitting patches or whatever bug fixing mechanism the project I'm using supports whenever I find one, I think that's a good start ;)
# Chris said on 22 August, 2006 01:21 PM
This is probably a bit of a painfully obvious question, but how does one use the Parameters property?  I only had a single additional control used before, but I'm not sure how to fit this into a collection in the .aspx declaration of the control.  Moreover, VS is complaining that Parameters is not a valid attribute of element AutocompleteTextBox, using the most up to date version.

Technically, I have another, probably bigger question, but one thing at a time here (want to see if the new version addresses the other before asking about it, but until it works there's no point)
# simoneb said on 22 August, 2006 04:00 PM
Hi Chris, sorry for the lack of documentations, I always give as obvious that people are using the Visual Studio designer to set the properties values.

The Parameters property is a collection property, and I chose to make it a content property, that is, its values appear between the opening and closing tags of the control itself.
I will update the post with an example of how to set it up.

However, if you use Visual Studio, setting the Parameters property is very straightforward since an intuitive collection editor pops up when you click the button next to the property name.
# Chris said on 22 August, 2006 04:01 PM
Okay, that was stupid, and I figured it ot in the two hours between posting it and it showing up, so I may as well continue with the the real issue.

It's working well on my own server, but the project is supposed to be served on the company's hosting share on 1&1.  Going to the page that uses the autocomplete box throws a System.Security.Permissions.FileIOPermission error (full details at http://tre-llc.com/tre/scriptaculous_error.txt).  A quick scan through the code shows that there isn't any file IO even happenin, and I don't know why it would want to anyway, except perhaps for caching (which I have switched off with the flag anyway), so I'm relatively stumped.  Why would this module throw that kind of error?
# Chris said on 22 August, 2006 04:11 PM
Sorry about posting again, particularly since my last one hasn't even shown up yet, but I never use the design view, partially in this case because I can't get the thing into the toolbox, and partially because I'm much more used to linux style web scripting with vim as the editor.  In code view though, it did work out really easily once I knew there was supposed to be a child <Parameters> with the children in it, which I got from looking over the code and then searching MSDN for what exactly the ParseChildren directive usually means for the client code.  I'm sure I'd have figured it out sooner if I wasn't intentionally being a luddite with the IDE, but it worked out eventually anyway.
# simoneb said on 22 August, 2006 04:32 PM
Chris, I'm stuck as well with the security exception. I tried checking required permissions with the permcalc tool but it really didn't expose any particular requirement.

I read that you can't get the controls into the toolbox, and I truly don't know why this should happen. I managed to get them into the toolbox more than once, but I often read about people unable to do that with other controls as well.

I think I'll have to investigate the security exception and this toolbox weirdness further. I'll eventually let you know about it. As you may have guessed I don't have much familiarity with the CAS, so I'll have to study it a but more I guess.

Again, the Parameters property, is as easy to set up int the source view because afaik VS gives you the intellisense there too, but glad you solved the issue.
# simoneb said on 22 August, 2006 08:50 PM
Hi Chris, I investigated the security exception a bit and discovered that the Assembly.GetName() method demands a FileIOPermission to get the path of the assembly. If you've looked at my code you have seen that I use reflection to perform the call to the method which supplies the suggestions, so I need to know the name of the assembly where the type containing that method is situated. I guess there's no workaround for this, but I'll let you know if I find one.
# Ozman said on 23 August, 2006 06:56 PM
This is in response to softer question about the scroll feature closing when selecting the scroll bar.

I would like to try and resolve this.
Would this fuction be found in the control.js.

I'm thinking there is on select function that applies to the UL item that is generated.

Any help would be aprreciated.

# Ozman said on 23 August, 2006 07:18 PM

Your advice I did the following and it worked.
Please review and let me know what you think.

Inside OnClick:Function .......  inside the control script..

I added if statement to verify that the event generating the onclick is a LI if so I alowed the
the hide and select entry.

I then commented out the OnBlur event.

Let me know, its working so far for me without any problems.

I also added a property called ScrollHeight to set the height of the scroll box.

# simoneb said on 23 August, 2006 07:26 PM
Thank you Ozman, Softer already sent me a great solution for this issue. The problem is that the javascript code is totally taken from the script.aculo.us original library, and I wanted to keep it as faithful as possible to the original code, so that future releases of the original library can be immediately integrated.

Ok, since you are asking I will try to work on it.
# Ozman said on 23 August, 2006 10:38 PM
Cool , no rush I have a working version for my needs. Only issue remaining is after adding the onblur event back , is stopping the onmouseout event when leaving the textbox to access the scroll bars.
# simoneb said on 24 August, 2006 02:31 AM
Ozman, check out the new version, the details about fixes and enhancements are in the post.
# Ozman said on 24 August, 2006 03:16 PM
Cool thanks for the new version it works great, and hard work.
# Chris said on 24 August, 2006 05:01 PM
I found a workaround.  I won't claim this is the cleanest way to do it, but it works like this:

internal static string GetSuggestionUrl(Type type, string method, string controlName, bool cacheSuggestions)
  string AssemName = type.Assembly.FullName;
  AssemName = AssemName.Substring(0, AssemName.IndexOf(','));
  return FormatSuggestionUrl(AssemName, type.FullName, method, controlName, cacheSuggestions);

Getting the FullName property doesn't require a FileIOPermission demand, but it returns too much data, which is easy enough to strip off.  With the assembly built in this way the page loads as expected.  There's no data there yet to make sure it actually fires off correctly, but locally (where there wasn't a security issue in the first place) it works exactly as before.

By the way, 1&1 has the security level set all the way down to safe mode, so almost nothing that requires any security demands will run.  Let this be a warning to anyone who wants to host their code there.
# simoneb said on 24 August, 2006 07:00 PM
Ozman, you'll have to thank Laurentiu Macovei who submitted the changes. He did a great work, I just merged his changes.

Chris, to tell the truth, the way I did it was the first which came to my mind when I first did it. I guess there are better ways and I'll try to find one. Unluckily many shared hosting providers have very strict security policies, for instance the Atlas Control Toolkit at the moment requires Full Trust and it's very likely that it won't work on any of those shared hosting spaces.
# simoneb said on 24 August, 2006 07:30 PM
Chris, the FileIOPermission should be fixed, let me know if you're still experiencing any issues. Thanks for investigating the problem.
# Kasi said on 24 August, 2006 08:22 PM
I tried using the AutoCompleteTextBox which seems to work well in most situations however I am using it inside of an Atlas UpdatePanel with AutoPostBack = True, and I'm trying to intercept the TextChanged event so that when an item is clicked from the autocomplete textbox I can take the value selected and use it to preform a task without reloading the page but when AutoPostBack is set to true when a click occurs in the autocompletetextbox suggestion it doesn't actually place the clicked value into the textbox as occurs when AutoPostBack is set to false. Is there anyway around this?
# simoneb said on 25 August, 2006 11:56 AM
Hi Kasi, I did some tests and I haven't been able to make it work too. The fact the the control works side-by-side with Atlas indeed doesn't necessarily mean that it works well in conjunction with it.
Since you're already using Atlas, I guess the best way of implementing an autocomplete pattern is to use the one already shipped with Atlas, or the  Smart Autocompletion you can find a link to in the former of my post.
# simoneb said on 25 August, 2006 12:09 PM
Hi again Kasi, I just managed to make it work.

Just place the AutocompleteTextBox outside of the UpdatePanel, and set the UpdatePanel trigger property to the Text property change of the AutocompleteTextBox. This way is working for me.
# Chris said on 25 August, 2006 12:10 PM
I didn't notice this at first, because you need something like Firefox's "View Rendered Source Chart" extension to pick up on it, but attempting to retrieve a suggestion is throwing errors that are only displayed in the hidden div.  If you have any idea what part of SuggestionHandler.ProcessRequest() is asking for a LinkDemand on System.Security.Permissions.SecurityPermission, it'd help greatly.

This is trivial, but the suggestion list background has been clear since the Laurentiu Macovei changes were merged in, whether I use the default or set SuggestionBackColor explicitly.  I'm not quite as worried about that since for the moment it only works at all on my laptop, and the only thing more absurd than an international company hosting their website on a $9.99 per month shared hosting plan would be serving from a ThinkPad T-23 hooked up to a T1 line.

Oh, I don't think I've said this, but thanks for making the control in the first place and all the support up until now.  It's not your fault we're trying to run the code under bone headded restrictions, and in a sane environment it'd be a great piece of work.
# simoneb said on 25 August, 2006 12:37 PM
Chris, I've investigated the CAS issues these days, and I realized that probably there's no way you can make it work under partial trust, because the SuggestionHandler class instantiates the Page where you created the method which supplies the suggestions via Reflection, and Reflection unluckily requires the web application to be running under Full Trust.

I created this library just for fun, and didn't consider such issues at all in the former, thus now I realize that in most situations it is useless because most hosters will never let your apps run under Full Trust.

About the backgroung being clear, it only happens when there is scrolling, just like it happened before. I indeed don't think that Laurentiu broke anything.

However thank you for your compliments!
# SimoneB's Blog said on 27 August, 2006 08:49 PM
Over the last few days the API of the ScriptAculoUs.Net AutocompleteTextBox control has changed pretty...
# Phil said on 10 September, 2006 07:21 PM
Hi, first of all - very good and easy to implement component, but when I tried it in Firefox and it freezes. It's very important to me a cross browser support. That's very pity, because I like it very much :(
# simoneb said on 10 September, 2006 09:52 PM

Hi Phil, it's a know bug introduced after merging the changes submitted by Laurentiu Macovei, and which I haven't been able to fix. The version you can find on the SVN repository doesn't have those changes merged in and shouldn't freeze in FF. Besides the repository copy introduces many major changes and since I didn't document them yet I suggest you read the post and watch the screencast I did about the new version: http://dotnetslackers.com/community/blogs/simoneb/archive/2006/08/28/460.aspx.

# Phil said on 11 September, 2006 04:21 AM
Thanks for a quick reply. I've been looking for a free autocomplete textbox for a while, but there always has been a huge bugs in others autocompletes, and since I'm not a very good javascript writer this control helped me very much. Great work !!!
# simoneb said on 11 September, 2006 06:31 AM

Thanks, glad I helped.

# Phil said on 11 September, 2006 09:13 AM
After some testing your latest 'source' version I found everything clear in IE and Firefox, but there have been some problems with Opera. Problem: In Opera 9.0.1 is the position of the results DIV incorrect (always on the top left corner) and when I select some item and press enter the page is post back. On the TAB key it's working correctly. but then I did some testing with official scriptaculous autocomplete (without your implementation in .NET) and it did the same bugs. But their demo (http://demo.script.aculo.us/ajax/autocompleter) is working with Opera perfectly, so I can't figure out where is the problem...
# simoneb said on 12 September, 2006 09:40 AM

Phil, I didn't test it in Opera, because I almost never used it as my own browser and very few people use it compared to people using FF and IE.

As far as I can guess maybe they realized that in their example it wasn't working too well in Opera and applied a workaround, probably with CSS.

I am not as a good javascript developer too, and I've already done many changes to the original script.aculo.us sources, which make it difficult to update my codebase whenever a new script.aculo.us release is out, so at the moment I prefer not to make anymore changes to the javascript. After all, script.aculo.us is developed by the Ruby community, which is far more active than we can be, and I guess and hope they will solve all those issues fast.

I will keep my source up to date with their releases.

# Phil said on 12 September, 2006 10:18 AM
Thanks for your answer. I am not using Opera too, but since it is a free version it is being more popular. But problem with the positioning was after some changes in controls.js magically solved. So the only problem is enter key and as you said since this isn't IE or Firefox it isn't so big problem :) The last thing - may I ask you if there is some list of changes of your actual version? So I can decide whether I change it or not (since I fix the Opera positioning)? Thanks...
# simoneb said on 12 September, 2006 10:58 AM

I am not keeping a changelog yet, but I'm planning to create one since this is becoming more than a simple webcontrol. Anyway the controls.js file is well documented with the changes and I use to log every small change I do whenever I commit them on the svn repository, so just give a look at the svn log.

However the major changes you can find on the repository now are in the fact that I am leveraging the ASP.NET built-in callback mechanism, and thus the control works using events instead of reflection to call the method which supplies the suggestions. The other major change is that I commented out from the controls.js file most of the changes submitted lately by Macovei because as you can see in the actual binary release they make the control freeze in FF.

If you have changes to submit I'd be glad if you created a patch and used the google hosting project page to submit it, but even better, if the changes concern the javascript code, create a patch on http://dev.rubyonrails.org/report/22, which is where the script.aculo.us and prototype codebase is kept.

# Gareth Evans said on 21 September, 2006 09:57 PM
Hey Simone. Great autocomplete control, i've used it a couple of times now. Just a quick query which I'm sure has been answered elsewhere but I know that scriptaculous has a bunch of other neat effects and the like that you can take advantage of in 'normal' web programming (ie: where you are manually assigning the event handlers to objects, particularly some neat drag and drop stuff i've seen on the demo site (however that uses rails which I am not familiar with)) I was wondering whether you are planning on expanding the .net control/library into taking advantage of some of the other features in the js library.. I'm pretty sure I could use client side bindings (fairly new to .net to be honest) to bind to the client functions directly but growing quite fond of drag&drop controls. :)
# simoneb said on 25 September, 2006 07:32 PM

Hi Gareth, thanks for your words. At the moment I'm not planning to implement anymore features of the original javascript library both because I have no time to work on it and then because I'm pretty sure that the Microsoft Ajax Library will grow consistently in the near future and will eventually include many of the features that it actually doesn't implement.

# Abe said on 26 October, 2006 03:11 PM
When autocompleted either via a <tab> or <enter> the onchange javascript event is not fired.
# adktd said on 09 November, 2006 04:44 AM
Fantastic control. I only have one question : Let's say that i use the control to retrieve a list of customers.I want to be able to know the selected customers id. Is there a way that i can do that?
# simoneb said on 13 November, 2006 09:38 PM

No sorry, you'll have to use a standard DropDownList for that.

# Robin said on 27 November, 2006 03:01 PM
Im in the same situation of ADKTD. i retrieve a list of customers but i need to know the key associated with the selected one on the list. Anyone can help me please ?
# simoneb said on 27 November, 2006 06:25 PM

Robin, as I have already said I don't think there's an easy way you can achieve that with any of the autocomplete solutions out there. I have no time to work on a workaround for that, but I suggest you to use a simple dropdownlist control.

# adktd said on 29 November, 2006 09:41 AM
It was very easy to implement your control to my form.Looks great. I only have one major problem. I get javascript errors now that have to do with the rest of my code which depends on ATLAS. I use the ATLAS version right before the latest Beta 1 of ASP.NET AJAX. The error has to do with the $() function of ATLAS. It somehow conflicts with ScriptAculous. Is there any way to overide this?
# simoneb said on 05 December, 2006 10:03 PM

You should switch to the latest MS Ajax release, since this solves the problems of incompatibility with other libraries.

# Mohammed said on 06 December, 2006 10:51 AM
Great Control. I would like to know how would i control the display item i.e. i want to reduce horizontal spaces between each item in the drop list. Thanks
# simoneb said on 06 December, 2006 09:37 PM

Hi Mohammed, you'll have to act on the stylesheet autogenerated by the control. I didn't directly expose that property 'cause I thhought it wouldn't be useful, but if you get the source it won't be hard to implement it.

# Mohammed said on 07 December, 2006 04:47 PM
Thanks for quick reply I did got the code, but i think there is difference in what i downlowded from this page and from the source. For Ex: From the source, there is no such property by Name "MethodName", i think it's done through OnAutoComplete. and the DropDown is disappearing if i click the scroll bars. Which one is the latest version ? Thanks
# Mohammed said on 07 December, 2006 04:48 PM
and as you said that i have to act on the styleshet. Can you shed some light on it? Thanks
# simoneb said on 07 December, 2006 07:35 PM

Yes, the source code is undergoing heavy refactoring. In the repository you'll find always the latest code, which at the moment is completely working. It exposes a new API which I haven't publicly released yet, but you can see a screencast of this new API at this blog post of mine: http://dotnetslackers.com/community/blogs/simoneb/archive/2006/08/28/460.aspx.

I know about the problem with the list disappearing when clicking the scrollbars, some time ago I introduced a fix submitted by a user but it was becoming too difficult to mantain because I wanted to keep the javascript as close as possible to the original script.aculo.us library (since I'm not a Javascript guru) and so I decided to revert to the original code, even if it introduces this sort of bug. I decided to act this way even because I'm very confident that the guys developing script.aculo.us (the same of Ruby on Rails) will solve this problem. Furthermore every time that they make a new release I update my control to reflect those changes, and so it was too much difficult to merge the changes each time. In substance I just wanted to develop a good wrapper, not create something from scratch, since it would then be too much demanding for me to take care of it.

If this bug truly annoys you, I know there are patches which don't have yet been merged in the issue tracker or the project at this url: http://dev.rubyonrails.org/report/22.

One patch is this one: http://dev.rubyonrails.org/ticket/6560 but I haven't tested it. Another one, which seems the most promising, is this one: http://dev.rubyonrails.org/ticket/4782.

About the stylesheet, in the AutocompleteTextBox file you find the overridden OnPreRender method. There you will wind the code which generates a stylesheet based on the properties set on the control. You can edit that code to include your custom css directives.

# Mohammed said on 08 December, 2006 09:24 AM
Thank you very much
# SimoneB's Blog said on 21 March, 2007 07:29 PM

Yesterday I got a link on my news aggregator pointing to a new article by Sam Judson on Coding4Fun ,

# SimoneB's Blog said on 21 March, 2007 07:37 PM

UPDATE: Now all my projects are grouped under one main repository located on Sourceforge, together with

# Andreas said on 27 March, 2007 08:33 AM
Hi it possible to retreive Textresult in the autocomplete but when you click on the name it's replaced with a value in the textbox?
# simoneb said on 28 March, 2007 05:23 PM

Andreas, the features of the control are the same as the control in the original script.aculo.us library, so if you are looking for a new feature you should ask the script.aculo.us team first.

# vero1965 said on 05 April, 2007 12:04 PM

Hi simone, i'm tring to understand how it works i've done that (at end it would be connected to a database, datareader i think)

public IEnumerable GetSuggestions(string key )
    ArrayList suggestions = new ArrayList();

    suggestions.Add("electrode enrobée");

    return suggestions;

but when i write something i've the whole liste of suggestions.... instead of having for typing : a, i should obtain atome at, i should have atome e, i should have electrons and electrode and electrode enrobée i begin in C#, that's why i don't understand all can you help me ? i would be so kind thanks in advance

# simoneb said on 05 April, 2007 01:29 PM

vero, returning the items corresponding to the typed characters is up to you. All the control does is supply them to you via the input parameter of the method.

# Jonathan said on 19 June, 2007 05:54 PM
Simon, Very nice control. I'm having problems using FireFox when the list displays and I use the up and down arrow keys, basically the screen freezes and I'm prompted to Terminate the Script after a couple of seconds. I'm not sure exactly what's causing it, but I can select with the mouse items fine. Have you encountered this issue before?
# simoneb said on 19 June, 2007 07:16 PM

Hi Jonathan, to tell the truth I haven't put my hands of the control for quite a while now. As you know, it's just a wrapper around the script.aculo.us javascript autocomplete control, so all the client-side functionality is supplied by that one - as well as the limitations.

Since the last release of my library script.aculo.us has made quite some releases, so I guess that downloading their latest one and recompiling my library with those updated javascript files may solve your issues. You should give a look at script.aculo.us release notes to see if they made any changes to the autocomplete control.

# susan said on 28 September, 2007 10:15 PM

One problem i had with this auto complete was that it wasn't smart enough... ie... if my search term was missing a word, it couldn't find what i was looking for.

For example, in a db of cameras if I was looking for a "Camera PowerShot sd800 Digital Elph"

but only remember the model number, not the full name ...so i'd type in "Canon SD800"...and itd give me nothing

It wasn't until i typed in "Canon PowerShot SD..." that it found something. I needed it to ignore that I had forgotten PowerShot

I found a real simple solution - which I describe in detail here - www.susanbuck.net/.../index.asp

# simoneb said on 28 September, 2007 11:34 PM

Glad you found a solution. Actually my implementation is just a wrapper around script.aculo.us control, but it's pretty straightforward to achieve this.

This site



This Blog




  • MaximumASP