Click here to Skip to main content
13,189,324 members (65,118 online)
Click here to Skip to main content
Articles » Web Development » Ajax » Controls » Downloads

Stats

638.2K views
6.7K downloads
148 bookmarked
Posted 23 Jan 2007

AJAX AutoComplete/AutoSuggest TextBox

, 2 Oct 2007
An article on AJAX AutoSuggest control
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
App_Code
App_Data
Bin
Anthem.AutoSuggest.dll
Anthem.AutoSuggest.pdb
Anthem.dll
Anthem.pdb
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.

I also have my own startup where we offer client intake forms.

You may also be interested in...

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