Total Pageviews

10/07/2011

How to use AJAX AutoComplete TextBox with SQL Store Procedure and Asp.net Web Service



Introduction


This article explains how to use AJAX AutoComplete TextBox with SQL Store Procedure and Asp.net Web Service


Description

AutoCompleteExtender is an ASP.NET AJAX tool that can be attached to TextBox control of Asp.net. When the member typing some keywords in the TextBox a dropdown panel will come in to action and related result will be displayed. So member can choose exact words from the panel by use of the arrow keys (Up / Down ) or mouse click. Here I will explain How to use AJAX AutoCompleteExtender with SQL Stored Procedures and Asp.net Web Service



1) Open Microsoft Visual Studio.

2) Click on New Website.

3) Select ASP.NET Ajax Enabled Website and change the location to point your http://localhost/AutoComplete folder. Obviously, Default.aspx is added to your solution explorer.

Default.aspx

         <form id="form1" runat="server">
         <asp:ScriptManager ID="ScriptManager1" runat="server">
         <Services>
         <asp:ServiceReference Path="AutoComplete.asmx" />
         </Services>
         </asp:ScriptManager>
         <div>
         <asp:TextBox ID="txtCountry" runat="server"></asp:TextBox>
         <ajaxToolkit:AutoCompleteExtender
         runat="server"
         ID="autoComplete1"
         TargetControlID="txtCountry"
         ServicePath="AutoComplete.asmx"
         ServiceMethod="GetCompletionList"
         MinimumPrefixLength="1"
         CompletionInterval="1000"
         EnableCaching="true"
         CompletionSetCount="12" />
         </div>
         </form>



Now drag and drop a Textbox from your Toolbox Pane. Then drag and drop a ScriptManager and AutoCompleteExtender to your Default.aspx page. Then add a webservice to your project as AutoComplete.asmx. First thing you have to do is to add the ScriptService reference to the webserive as follows.

Now, write a webmethod ‘GetCountryInfo’ to fetch the data from the store procedure as follows



AutoComplete.asms.cs

       [WebService(Namespace = "http://tempuri.org/")]
       [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
       [System.Web.Script.Services.ScriptService]

       public class AutoComplete : System.Web.Services.WebService
     {

        public AutoComplete()
       {
        }

        [WebMethod]
        public string[] GetCompletionList(string prefixText, int count)
        {

          Database _db = DatabaseFactory.CreateDatabase("Connection string here");
          DataSet ds;
          SqlCommand objCommand = new SqlCommand("GetCountryInfo");
          objCommand.CommandType = CommandType.StoredProcedure;
          objCommand.Parameters.AddWithValue("@Country", prefixText);

          ds = _db.ExecuteDataSet(objCommand);
          // return ds.Tables[0];

          string[] items = new string[ds.Tables[0].Rows.Count];
          int i = 0;
          foreach (DataRow dr in ds.Tables[0].Rows)
          {
            items.SetValue(dr["CountryName"].ToString(), i);
            i++;
          }
          return items;


          }

      }

See Example Here :


free gif maker


Download Demo


92 comments:

Pravesh Singh said...

This is best one article so far I have read online. I would like to appreciate you for making it very simple and easy. I have found another nice post related to this post over the internet which also explained very well. For more details you may check it by visiting this url…….
http://mindstick.com/Articles/a7e242ef-fd21-4d4a-8cc6-ccbf4972be65/?Ajax%20Toolkit%20AutoCompleteExtender%20Control%20in%20Asp.Net

Anonymous said...

excellent . very detailed and to the point description

Anonymous said...

Nothing better then this thanks bhavik, Please keep posting similer post for us to look and follow.....

Erasmus Hays said...

It is a combined attempt between Microsoft company and the ASP.NET AJAX group that provides a highly effective facilities to create reusable, personalized and extensible ASP.NET AJAX traction devices and manages.

Unknown said...

Hi... A quick question... How to find Database and DatabaseFactory?

Jesica Paul said...

Excellent post!!! Java is most popular and efficient programming language available in the market today. It helps developers to create stunning desktop/web applications loaded with stunning functionalities. J2EE Training in Chennai | JAVA Training in Chennai

mathew delport said...

Nice tutorial on android technology hats-off to your effort. Your article explained the potential of android technology in coming years. Android Training in Chennai

murali karthik said...

There are lots of information about hadoop have spread around the web, but this is a unique one according to me. The strategy you have updated here will make me to get to the next level in big data. Thanks for sharing this. Hadoop Training in Chennai | Big Data Training in Chennai

murali karthik said...

.Net is most preferred programming language among software developers all over the world. It is also considered as most trusted and effective platform to build high performing desktop or enterprise application. DOT NET Training Institutes in Chennai

murali karthik said...

I agree with your post. Android software development kit makes the application development process lot simpler and effective. You can create best performing android application with ease. Android Training Institutes in Chennai | Android Training in Chennai

Jhon David said...

Upgrading ourselves to the upcoming technology is the best way to survive in this modern and fast paced technology world. Reading contents like this will create a positive impact within me. Thanks for writing such a valuable content. Keep up this work.

JAVA Training in Chennai

savitha singh said...

Informative post on Android mobile application development!!! As the usage of iPhones keep on increasing, there is massive demand for best performing Apps and Games for iOS platform. Best IOS Training in Chennai

Jhon Abraham said...

Updating with the latest technology and implementing it is the only way to survive in our niche. Thanks for making me understand through this article. You have done a great job by sharing this content in here. Keep writing article like this.

DOT NET Training in Chennai | .net training in chennai | DOT NET Course in Chennai

Bay Max said...

Android is consider the best operating system for any mobile devices except in the international market. Since the invention the software has met several updates till now.Your content is also reminding that to me now. Thanks for sharing this wonderful information in here.


Android training centers in chennai | Android training center in chennai

Mathew Stephen said...

Excellent post.Training on android technology helps professionals to establish a career in android mobile application development.
Thanks,
Android courses in Chennai | Android Training

Jhon anderson said...

Nice post.It is really interesting to read and I got good information from your post.Keep update your blog with such awesome information.
Thanks,
DOTNET Training in Chennai | DOTNET Training Institute in Chennai | Best DOTNET Training in Chennai

Nikshitha S said...

Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
Web designing Course in Chennai | Hadoop Training in Chennai

Paul Miller said...

Nice to see this blog.Thanks for sharing the Ajax autocomplete text box process.I will follow your steps.It is working.Keep sharing more like this.
Selenium Training in Chennai | Software Testing Training in chennai | Digital Marketing Training in Chennai

Arthur Mac said...

Good information to know and right to the point. Thanks for this well written post, i'll follow up for more updates if you keep posting them
Java Training in chennai | Java course in chennai | JAVA J2EE Training Institutes in Chennai

Arthur Mac said...

Hadoop is the most well known language.Initially hadoop is created for huge measure of information sets in OLAP environment. With presentation of Hbase on top of hadoop, can be utilized for OLAP Processing moreover. Hadoop is a structure with all the subcomponents like guide reduce,hdfs,hbase,pig.Start to learn Hadoop course.It will helps you to achieve a wonderful career.
Regards,
Hadoop Training Chennai | Bigdata course in Chennai | Bigdata Training Chennai

Amirtha rao said...

Hi Admin, I went through your article and it’s totally awesome. You can consider including RSS feed for easy content sharing, So that you can drive huge traffic to your blog. Hadoop Training in Chennai | Big Data Training in Chennai

Geetha Devi said...

Great blog.Thank you for sharing Best Selenium Training in Chennai |Selenium Training in Chennai | Best Selenium Training Center in Chennai
Android Training in Chennai

Rasool Bevi said...

It's a good guide about to use ajax.
Regards,
Cloud Computing Courses|cloud computing training institutes in chennai

Priya R said...

Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
cloud computing training in chennai | cloud computing courses in chennai

geethu said...


The strategy you have posted on this technology helped me to get into the next level and had lot of information in it. The python programming language is very popular and most widely used.
Python Training in Chennai | Python Course in Chennai

Nandhini said...

Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
Android training in Chennai | Android course in Chennai

Priya R said...

Thanks for sharing this unique and informative content which provided me the required information.
Java Training in Chennai | JAVA Course in Chennai

Priya R said...

The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
Dot net training in Chennai | dot net course in Chennai

sunilkumarkuppam said...

Thanks for sharing the information about the java and keep updating us.
JAVA Training in Chennai

Best JAVA Training in Chennai

Amirtha rao said...

Thanks for sharing this valuable information to our vision. You have posted a trust worthy blog keep sharing.

cloud computing training in chennai|cloud computing training|Cloud Computing Courses

jhansi joe said...

This information is impressive; I am inspired with your post writing style & how continuously you describe this topic. After reading your post, thanks for taking the time to discuss this, I feel happy about it and I love learning more about this topic.
Salesforce Course in Chennai|Salesforce Training Chennai|salesforce developer training in chennai

for IT the said...

Wow. This really made my day. Thanks a lot!

JavaScript Online Training | HTML5 Online Training JQuery Online Training JQuery Online Training Javascript Online Training

for IT the said...

Angularjs Online Training
JavaScript Training Courses | Javascript Online Training | Angular 2 Online Training

for IT the said...

JavaScript Online Training JavaScript Online Training JQuery Online Training JQuery Online Training
JavaScript Course | HTML5 Online Training

for IT the said...

JavaScript Training in CHennai HTML5 Training in Chennai HTML5 Training in Chennai JQuery Training in Chennai JQuery Training in Chennai JavaScript Training in Chennai JavaScript Training in Chennai

Melisa said...

Damn good content :) keep on posting
Regards,
J2EE Training in Chennai|JAVA Training Chennai

Mohana M said...

Hi, you have given really informative post. Thanks for sharing this post to our vision. Learn Hadoop Online Training will helps you to reach your goal.Selenium Training

Mohana M said...

Hi, I am really happy to found such a helpful and fascinating post that is written in well manner. Thanks for sharing such an informative post. keep update your blog.R Programming Online Training

Paul Miller said...

Excellent post!!! The future of .net application development is on positive note. It offers huge career prospects for talented professionals all over the world. Training on .net technology will ensure good salary package. Best DOT NET Training in Chennai | .NET Course in Chennai

Melisa said...

Nowadays, most of the businesses rely on cloud based CRM tool to power their business process. They want to access the business from anywhere and anytime. In such scenarios, salesforce CRM will ensure massive advantage to the business owners. Salesforce Training | Salesforce Training in Chennai

Evelin Harriet said...

Nice Blog. Thank you for Sharing the great information!
erp software companies in chennai | erp software providers in chennai

Shivani Yuvanjalin said...

I like it your blog. Thank you for Sharing the great information!
erp in chennai | erp providers in chennai

Melisa said...

In coming years, cloud computing is going to rule the world. The cloud based CRM tool provider like Salesforce have massive demand in the market. Thus talking Cloud Computing Training in Chennai from reputed Cloud Computing Courses will ensure bright career prospects for aspiring professionals.

sivanesan said...

Excellent post. I have read your blog it's very interesting and informative. Keep sharing.
erp software in chennai

Amirtha rao said...

Excellent post!!! In this competitive market, customer relationship management plays a significant role in determining a business success. That too, cloud based CRM product offer more flexibility to business owners to main strong relationship with the consumers. Cloud Computing Training in Chennai | Salesforce Training in Chennai

Brave Technologies said...

Thank you for this valuable information.
cloud erp software providers in chennai
erp software solutions in chennai
erp for leather company in chennai
erp for automotive industries in chennai
erp for trading company in chennai
erp for franchse management in chennai
erp for construction & industrial management in chennai

Tina Kenard said...

In coming years, cloud computing is going to rule the world. The cloud based CRM tool provider like Salesforce have massive demand in the market. Thus talking Cloud Computing Training in Chennai from reputed Cloud Computing Courses will ensure bright career prospects for aspiring professionals.

Rasool Bevi said...

In near future, big data handling and processing is going to the future of IT industry. Thus taking Hadoop Training in Chennai | Big Data Training in Chennai will prove beneficial for talented professionals.

Amirtha rao said...

Hi, JAVA is not at all difficult all you need is to clear your concepts mainly because the concepts of JAVA programming have been taken from day to day life examples.J2EE Training in Chennai | JAVA Training in Chennai

Rasool Bevi said...

Informative article !!! With the expansion of mobile phones, most of us access internet from our mobile and other portable gadgets. Having responsive website for your business will help you to target customers widely. web designing course | Web designing course in Chennai | website design in Chennai

Mathew Stephen said...

These all are notable facts… I stick with responsive website design for my business. With the mobile marketing is at its peak stage, having website that goes comfy on all devices will help your business. You can check my website for more details on the importance of responsive website design. PHP Training Institute in Chennai | Best PHP training in Chennai | PHP Training Institute in Chennai

Amirtha rao said...

Hi Admin, I went through your article and it’s totally awesome. You can consider including RSS feed for easy content sharing, So that you can drive huge traffic to your blog. Hadoop Training in Chennai | Big Data Training in Chennai

Bay Max said...

Your website is totally awesome and loaded with various informative posts on web design and development. Keep on updating your blog. Web Design Training | Web designing course in Chennai

manju said...

I learned so many things from your post. Thank you for sharing such a wonderful blog.. Dot Net Training Institute in Chennai | Dot Net Training Institute in Velachery.

Nandhini said...

Thank you for sharing such a nice and interesting blog with us. Hope it might be much useful for us. keep I have read your blog its very attractive and impressive. I like it your blog...Android Training in Bangalore

Nandhini said...

This information is impressive; I am inspired by your post writing style & how continuously you describe this topic... Android Training in Bangalore

srihariparu said...

I have read your blog its very attractive and impressive
CCNA Training Institute in Chennai | CCNP Training Institute in Chennai | No.1 CCNA Training in Chennai | Best CCNP Training in Chennai

Bashir Nisha said...

Wow! What a explanation of SQL Concept., Really its very useful to me., I got some information with the help of your blog. Web Designing Training in Chennai | Selenium Training in Chennai

Krishna Veni said...

Good and interesting article, it is very useful to me.. thanks for sharing your information and views.. keep updating and rocks..

Android Training in chennai | IOS Training in chennai

sharma said...

Nice blog.You shared very useful post. Thanks for sharing..Web Designing Training Institute in Chennai | Web Designing Training Institute in Velachery.

ALINAAMEL said...

I would like to say thank you for the amazing details and concepts you are sharing in this.
Webseiten Gestaltung L├╝denscheid

srihariparu said...

I am reading your post. It's very useful information for us. keep sharing..
VLSI Project Center in Chennai | VLSI Project Center in Velachery

chandhu said...

Excellent post. Keep updating.I have got some useful information form this article.
Java Project Center in Chennai | Best Java Projects in Velachery

annika romy said...

I found a lot of interesting information here. A really good post
office 2010 professional plus key deutsch

Andria BZ said...

Nice piece of information on HTML5. With the expansion of smartphones and other portable gadgets, the demand for responsive website design that go comfy on all devices keeps on increasing. This leads to invention and expansion of HTM5 web technology.PHP Training in Chennai

ancy said...

his is excellent information. It is amazing and wonderful to visit your site. Thanks for sharing this information..Mobile Computing Projects Center in Chennai | Mobile Computing Projects Center in Velachery

selva a said...

Interesting post! This is really helpful for me. I like it! Thanks for sharing!
No.1 MBA Project Center in Chennai | No.1 MBA Project Center in Velachery

Inigo joseph said...

Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site. php training in chennai

deepti said...

This is really great article. This article really impressed me through wonderful writing. So thanks for sharing such a awesome article. best power inverer
No.1 PHP Project Center in Chennai | No.1 PHP Project Center in Velachery

ajay said...

Good and nice information, thanks for sharing your views and ideas through this blog, nice content...Power System Projects Center in Chennai | Power System Projects Center in Velachery

anudeep bichal said...

nice ajax post regarding autocomplete textbox

java training in bangalore

Renith Harsan said...

Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.selenium training in bangalore

Renith Harsan said...

Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.selenium training in bangalore

Gowri S said...

I enjoy what you guys are usually up too. This sort of clever work and coverage! Keep up the wonderful works guys I’ve added you guys to my blog roll.
big data training in Chennai

peter said...

Those guidelines additionally worked to become a good way to
recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

java training in chennai


java training in bangalore



java training in bangalore

peter said...

Those guidelines additionally worked to become a good way to
recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.

java training in chennai


java training in bangalore



java training in bangalore

deepti said...

Interesting post! This is really helpful for me. I like it! Thanks for sharing!
Cloud Computing Project Center in Chennai | Cloud Computing Projects in Velachery | Cloud Computing Training in Chennai | Online Training Institute in Chennai

brunagari said...

Thanks For Your valuable posting, it was very informative
Schulungsangebote

SachinVarshan said...

I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
aws training in Chennai

brunagari said...

Nice article, I loved it.
personalrekrutierung

SachinVarshan said...

I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
python training in Chennai

brunagari said...

http://www.all-about-software-applications-repackaging.com/2012/11/how-to-determine-if-file-is-assembly.html

Steve M said...

Very useful content you have shared. Really great. Thank you.

PHP Training in Chennai
PHP Course in Chennai

Vishal said...

I believe there are many more pleasurable opportunities ahead for individuals that looked at your site..DotNet Project Center in Chennai | DotNet Project Center in Velachery

adhi said...

This is the best place where we can get good collection of information with an ease...
VMware Exam Centers in Chennai | VMware Exam Centers in Velachery

Mary Adlena said...

Great blog..Keep sharing...
Citrix Exams in Chennai | Xenapp exam center in Chennai

mallika said...

I read this article. I think You put a lot of effort to create this article.I appreciate your work..MatLab Project Center in Chennai | MatLab Project Center in Velachery

ancy said...

Good and nice blog post, thanks for sharing your information.. it is very useful to me.. keep rocks and updating.
OCJP Exam Center in Chennai | OCJP Exam Center in Velachery

muthu said...

Nice Article.. thank you for sharing...its was very interesting to read...Java Project Center in Chennai | Java Project Center in Velachery

krishna swamy said...

This is the best place where we can get good collection of information with an ease...
VMware Exam Centers in Chennai | VMware Exam Centers in Velachery

lotus said...

Thanks for sharing nice information. I like your post and all you share with us is uptdate and quite informative..Java Project Center in Chennai | Java Project Center in Velachery

fawaz shaik said...

Wonderful post to sharing..Thank you..MatLab Project Center in Chennai | MatLab Project Center in Velachery

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Affiliate Network Reviews