Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » Ajax » Controls » Downloads
 
Add your own
alternative version

AJAX AutoComplete/AutoSuggest TextBox

, 2 Oct 2007
An article on AJAX AutoSuggest control
autosuggestbox.zip
AutoSuggestBox
AutoSuggestBox
AutoSuggest
AutoSuggest.suo
AutoSuggest
Anthem.AutoSuggest.csproj.user
bin
Debug
Anthem.AutoSuggest.dll
Anthem.dll
Release
Anthem.AutoSuggest.dll
Anthem.AutoSuggest.pdb
Anthem.dll
Anthem.pdb
includes
vssver2.scc
Properties
Example
App_Code
App_Data
Bin
Anthem.AutoSuggest.dll
Anthem.AutoSuggest.pdb
Anthem.dll
Anthem.pdb
example.zip
Example
App_Code
App_Data
sample.zip
Bin
Anthem.AutoSuggest.dll
Anthem.AutoSuggest.pdb
Anthem.dll
Anthem.pdb
sourcefiles.zip
AutoSuggest
Anthem.AutoSuggest.csproj.user
bin
Debug
Anthem.AutoSuggest.dll
Anthem.dll
includes
vssver2.scc
Properties
using System;
using System.Text;
using System.Web;


namespace Anthem
{
	/// <summary>Data structure for menu items in suggestion div</summary>
	public class AutoSuggestMenuItem
	{
		private string _text;
		private string _value;
		private bool _isSelectable;
		private string _cssClass;
        private string _textBoxText;

		#region Class Properties
		
		public string Text
		{
			get	{return _text;}
			set	{_text=value;}
		}

		public string Value
		{
			get	{return _value;}
			set	{_value=value;}
		}

		
		public bool IsSelectable
		{
			get	{return _isSelectable;}
			set	{_isSelectable=value;}
		}

		public string CSSClass
		{
			get	{return _cssClass;}
			set	{_cssClass=value;}
		}

        public string TextBoxText
        {
            get { return _textBoxText; }
            set { _textBoxText = value; }
        }
		#endregion


		//Constructor
		public AutoSuggestMenuItem()
		{
			_cssClass="asbMenuItem";
			_isSelectable=true;
		}


		public string GenHtml(int nItemIndex, string sTextBoxID)
		{
			string sMenuItemValueID;
			string sFunc1;
			string sFunc2;
			
			string sHtml="";
			if (this.IsSelectable)
			{
				string sCtrlID=sTextBoxID + "_mi_" + nItemIndex;
				string sObj="asbGetObj('" + sTextBoxID + "')";

				sFunc1=sObj + ".OnMouseClick(" + nItemIndex + ")";
				sFunc2=sObj + ".OnMouseOver(" + nItemIndex  + ")";
				
				sHtml += "<div class=\"" + this.CSSClass + "\"" +
								" id=\"" + sCtrlID + "\"" +
								" name=\"" + sCtrlID + "\"" +
								" value=\"" + System.Web.HttpUtility.HtmlEncode(this.Value) + "\"" +
                                " textboxdisplay=\"" + System.Web.HttpUtility.HtmlEncode(this.TextBoxText) + "\"" +
								" onclick=\"" + sFunc1 + "\"" + 
								" onmouseover=\"" + sFunc2 + "\">" + this.Text + "</div>";
				sMenuItemValueID=sCtrlID + "_value";
				sHtml += "\n\r";
			}
			else
			{
				sHtml += "<div class=\"" + this.CSSClass + "\" style=\"cursor:auto\">" + this.Text + "</div>";
			}

			return sHtml;
		}
	}

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Cassio Mosqueira
Software Developer (Senior) Intelligent Coder
Canada Canada
I've been developing .NET enterprise applications since 2000.
 
I am originally from Rio de Janeiro and I am currently working at http://www.intelligentcoder.com in Ontario.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 2 Oct 2007
Article Copyright 2007 by Cassio Mosqueira
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid