[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

08/31/2009 at 09:16AM PDT, ID: 24695226
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.4

Ajax AutoCompleteExtender not working

Asked by vvvvv1 in Scripting Languages, Web Services, WebApplications

Hi,
I have one textbox, if i type something on that textbox it should search on my database and list the matching text like in a google suggest.

I have browsed and implemented a piece of code by using AutoCompleteExtender in Ajax. But it is not working. It is showing the textbox in the browser and also allowing me to edit. but no suggestion are displaying

I am very new this technology. I require your help to implement autoCompleteextender concept.
Please find my code below and advice me for the correction

Thank you in advance.

Regards,
ven

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
Default.aspx code:
 
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
 
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<script language ="javascript">
 
 
 
function ShowIcon() {
 
    string[] ret = WebService.HelloWorld(document.getElementById("TextBox1").value,10,OnComplete,onerror,"Country");
     //rep_id.DataSource = ret;
     //rep_id.DataBind();
    
 
}
function onerror(arg)
{
alert("Error in calling");
}
function OnComplete(arg)
{
rep_id.DataSource = ret;
rep_id.DataBind();
//document.getElementById("callres").innerHTML = arg;
}
</script>
 
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    <Services >
    <asp:ServiceReference Path="~/WebService.asmx" />
    </Services>
    </asp:ScriptManager>
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="TextBox1" 
        ServicePath="~/WebService.asmx" ServiceMethod="HelloWorld" MinimumPrefixLength="2"
        EnableCaching="true" CompletionSetCount="25" OnClientItemSelected="ShowIcon">
        </cc1:AutoCompleteExtender>
        
    </div>
    <div id="callres">
    
    </div>
    
<asp:Repeater id="rep_id" runat="server" >
 
<HeaderTemplate>
<table border="1" width="100%">
<tr>
<th>Country </th>
 
</tr>
</HeaderTemplate>
 
<ItemTemplate>
<tr>
<td><%#DataBinder.Eval(Container.DataItem,"Country") %></td>
</tr>
</ItemTemplate>
 
<FooterTemplate>
</table>
</FooterTemplate>
 
</asp:Repeater> 
</form>
</body>
</html>
 
 
Webservice.cs:
 
using System;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using System.Configuration;
using System.Data;
 
 
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
 
using System.Reflection;
 
using System.Collections.Generic;
 
 
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService
{
    private System.Data.Odbc.OdbcConnection OdbcCon;
    private System.Data.Odbc.OdbcCommand OdbcCom;
    private System.Data.Odbc.OdbcDataReader OdbcDR;
    private string ConStr;
 
    public WebService()
    {
 
        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }
 
    [WebMethod]
    public string[] HelloWorld(string prefixText, int count)
    {
        List<string> names = new List<string>();
        ConStr = "DRIVER={MySQL ODBC 3.51 Driver};SERVER=" + "localhost" + ";PORT=" + "3306" + ";DATABASE=" + "terminal_details" + ";UID=" + "root" + ";PWD=" + "root" + ";OPTION=3";
        OdbcCon = new System.Data.Odbc.OdbcConnection(ConStr);
        if (OdbcCon.State == ConnectionState.Closed)
        {
            OdbcCon.Open();
        }
 
        if (OdbcCon.State == ConnectionState.Open)
        {
            string constring = "Select Country_name from Country Where Country_Name like '"+@prefixText+"'";
            OdbcCom = new System.Data.Odbc.OdbcCommand(constring, OdbcCon);
            OdbcDR = OdbcCom.ExecuteReader();
 
            if(OdbcDR.HasRows)
            {
                while (OdbcDR.Read())
                    names.Add(OdbcDR[0].ToString());
 
            }
 
            
            return (string[])(names.ToArray());
        }
        return (string[])(names.ToArray());
    }
}
[+][-]08/31/09 10:05 PM, ID: 25228642

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Scripting Languages, Web Services, WebApplications
Sign Up Now!
Solution Provided By: vvvvv1
Participating Experts: 0
Solution Grade: A
 
 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625