Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi, I already made an autocomplete extender functionality and it is working fine on IE, but when running it in Google Chrome, it is not working. So can anyone help me please?

This is my code :
In Html:

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<!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>
<body>
    <form id="form1"  runat="server">
     <asp:ToolkitScriptManager ID="ScriptManager2" runat="server"  EnablePartialRendering="true" > 
    <services> 
    <asp:ServiceReference Path="DataService.asmx" /> 
    </services> 
     
    <div>
    
        <asp:TextBox ID="TextBox1" runat="server">
        <asp:AutoCompleteExtender BehaviorID="AutoCompleteExtenderBehaviour" ID="TextBox1_AutoCompleteExtender" runat="server" 
          MinimumPrefixLength="1"  CompletionSetCount="10"  DelimiterCharacters=""  ShowOnlyCurrentWordInCompletionListItem="true" Enabled="True" ServicePath="DataService.asmx" TargetControlID="TextBox1" ServiceMethod="GetCities">
        <animations>
                <onshow>
                    <sequence>
                         <hideaction visible="true"></hideaction>
                         <fadein duration=".50" fps="10" />
                    </sequence>
                </onshow>
                <onhide>
                    <sequence>
                         <hideaction visible="true"></hideaction>
                         <fadeout duration=".50" fps="10" />
                    </sequence>
                </onhide>
           </animations>
        
       
        <br />
        <br />
        
    
    </div>
    </form>
</body>
</html>


In Webservice :
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.Data;
using System.Collections.Generic;

[WebService(Namespace = "http://temf.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
 [System.Web.Script.Services.ScriptService]
public class DataService : System.Web.Services.WebService {

     public static IList<string> _cityList;
    public DataService () {

       //InitializeComponent(); 
    }

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

        //Gets the city list
       IList<string>  cityList = GetCityData();

        //using linq to select the cities based on the prefix text
        var result = from city in cityList.AsEnumerable()
                     where city.ToUpper().StartsWith(prefixText.ToUpper())
                     select city;
        //return the result as a string[] by taking only the top n
        return result.Take(count).ToArray<string>();
    }
    private IList<string> GetCityData()
    {
        if (_cityList == null)
        {
            CreateCityList();
        }

        return _cityList;
    }
    private static void CreateCityList()
    {
        _cityList = new List<string>();
        _cityList.Add("Boston");
        _cityList.Add("NewYork");
        _cityList.Add("California");
        _cityList.Add("New Jersey");
        _cityList.Add("Denver");
        _cityList.Add("Detroit");
        _cityList.Add("Idaho");
        _cityList.Add("Ohio");
        _cityList.Add("Los Angeles");
        _cityList.Add("Las Vegas");
        _cityList.Add("Philadelphia");
        _cityList.Add("Phoenix");
        _cityList.Add("San Antonio");
        _cityList.Add("San Diego");
        _cityList.Add("Dallas");
        _cityList.Add("San Jose");
        _cityList.Add("San Francisco");
        _cityList.Add("Columbus");
        _cityList.Add("Seattle");
        _cityList.Add("Washington");
        _cityList.Add("Oklahoma City");
        _cityList.Add("New Orleans");
        _cityList.Add("Honolulu");
        _cityList.Add("Virginia Beach");
    }    
}

</string></string></string></string></string>
Posted
Updated 26-Jan-11 5:51am
v3
Comments
Manfred Rudolf Bihy 25-Jan-11 15:46pm    
Pleas don't repost your questions. This is not tolerable! Your repost has been deleted.

To make life easier for you it would be best to use cross browser compatible javascript libraries. I suggest jQuery and PrototypeJS:
http://prototypejs.org/[^]
http://jquery.com/[^]
Using these libraries you don't have to do all the hard stuff yourself. You may want to check though which broswers in which versions are supported.

Best Regards,
Manfred
 
Share this answer
 
v2
Comments
mhamad zarif 25-Jan-11 15:08pm    
Thanks for your help,but is there another way to solve this problem ? since i must what iam doing and i do not have enough time to study new technologies.Thanks in advance.
Manfred Rudolf Bihy 25-Jan-11 15:44pm    
Then you'll have to debug your javascript: "Page/Developer/Javascript Console" in Google Chrome. This should give you enough hints which parts of your javascript is giving you problems.
Bryian Tan 25-Jan-11 19:06pm    
Hi,
Please post your code, so that we can easily replicate your problem. or do you have the link to the web application?
mhamad zarif 26-Jan-11 13:45pm    
Hi,i pasted my code up so i hope that you check it please.Thanks in advance.
Bryian Tan 26-Jan-11 14:18pm    
hello,
It works on Google Chrome. I'm testing it with your webservice and the markup code from. I tried to use the markup code you provided but didn't work, getting run-time error. So, what exactly is not working on Google Chrome? any error message?

http://www.asp.net/ajaxlibrary/HOW%20TO%20Use%20the%20AutoComplete%20Control.ashx
I am also having similar problems with Chrome and Ajax JQuerry call to the handler ashx.
After several hours of searching, I found that the problem is between Chrome and how the response is returned.
The mode of response must be end completed only by:
context.Response.Flush();
//    context.Response.Close();   //  Chrome problem //
context.Response.End();

Especially do not use "context.Response.Close()" I've read there post
It is "Close" which cuts the connection that triggers the error in Chrome.

Hoping that it might be useful to all.

PCMF
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900