Ajax what could be causing this?

M

mazdotnet

Hi,

I have setup the AjaxToolKit on my box which works great (cleaned up
their sample code for AutoCompleteExtender). However, when I import
the same code in my current project, it doesn't fire the webservice
that's suppose to return the auto complete results. What could be
causing this in my project? No compilation error, other AJAX
components work fine. Could be something in web.config file? I've
included my code below


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

<%@ Register assembly="AjaxControlToolkit"
namespace="AjaxControlToolkit" tagprefix="ajaxtoolkit" %>

<!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>Test</title>
</head>
<body>

<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager runat="server"
ID="ScriptManager1" />

<asp:TextBox runat="server" ID="myTextBox" Width="300"
autocomplete="off" />
<ajaxToolkit:AutoCompleteExtender
runat="server"
BehaviorID="AutoCompleteEx"
ID="autoComplete1"
TargetControlID="myTextBox"
ServicePath="AutoComplete.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="1"
CompletionInterval="100"
EnableCaching="true"
CompletionSetCount="20"

CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"

CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=";, :">
</ajaxToolkit:AutoCompleteExtender>

</form>
</body>
</html>


In my AutoComplete.asmx
<%@ WebService
Language="C#"
CodeBehind="/App_Code/AutoComplete.cs"
Class="AutoComplete" %>


In App_Code folder AutoComplete.cs

using System;
using System.Collections.Generic;
using System.Web.Services;

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

[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
if (count == 0)
{
count = 10;
}

if (prefixText.Equals("xyz"))
{
return new string[0];
}

Random random = new Random();
List<string> items = new List<string>(count);
for (int i = 0; i < count; i++)
{
char c1 = (char)random.Next(65, 90);
char c2 = (char)random.Next(97, 122);
char c3 = (char)random.Next(97, 122);

items.Add(prefixText + c1 + c2 + c3);
}

return items.ToArray();
}
}

Thank you
Maz
 
C

Cowboy \(Gregory A. Beamer\)

Do you have all of the bits in the web.config file that would be there when
you created the "other" site? You might be missing a config element which
works with the Auto Complete Extender.

I have not personally played a lot with AJAX lately, but that is the first
thing that comes to mind.


mazdotnet said:
Hi,

I have setup the AjaxToolKit on my box which works great (cleaned up
their sample code for AutoCompleteExtender). However, when I import
the same code in my current project, it doesn't fire the webservice
that's suppose to return the auto complete results. What could be
causing this in my project? No compilation error, other AJAX
components work fine. Could be something in web.config file? I've
included my code below


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

<%@ Register assembly="AjaxControlToolkit"
namespace="AjaxControlToolkit" tagprefix="ajaxtoolkit" %>

<!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>Test</title>
</head>
<body>

<form id="form1" runat="server">
<ajaxToolkit:ToolkitScriptManager runat="server"
ID="ScriptManager1" />

<asp:TextBox runat="server" ID="myTextBox" Width="300"
autocomplete="off" />
<ajaxToolkit:AutoCompleteExtender
runat="server"
BehaviorID="AutoCompleteEx"
ID="autoComplete1"
TargetControlID="myTextBox"
ServicePath="AutoComplete.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="1"
CompletionInterval="100"
EnableCaching="true"
CompletionSetCount="20"

CompletionListCssClass="autocomplete_completionListElement"
CompletionListItemCssClass="autocomplete_listItem"

CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
DelimiterCharacters=";, :">
</ajaxToolkit:AutoCompleteExtender>

</form>
</body>
</html>


In my AutoComplete.asmx
<%@ WebService
Language="C#"
CodeBehind="/App_Code/AutoComplete.cs"
Class="AutoComplete" %>


In App_Code folder AutoComplete.cs

using System;
using System.Collections.Generic;
using System.Web.Services;

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

[WebMethod]
public string[] GetCompletionList(string prefixText, int count)
{
if (count == 0)
{
count = 10;
}

if (prefixText.Equals("xyz"))
{
return new string[0];
}

Random random = new Random();
List<string> items = new List<string>(count);
for (int i = 0; i < count; i++)
{
char c1 = (char)random.Next(65, 90);
char c2 = (char)random.Next(97, 122);
char c3 = (char)random.Next(97, 122);

items.Add(prefixText + c1 + c2 + c3);
}

return items.ToArray();
}
}

Thank you
Maz
 
M

mazdotnet

Do you have all of the bits in the web.config file that would be there when
you created the "other" site? You might be missing a config element which
works with the Auto Complete Extender.

I have not personally played a lot with AJAX lately, but that is the first
thing that comes to mind.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my bloghttp://gregorybeamer.spaces.live.com/lists/feed.rss

*************************************************
| Think outside the box!
|



I have setup the AjaxToolKit on my box which works great (cleaned up
their sample code for AutoCompleteExtender). However, when I import
the same code in my current project, it doesn't fire the webservice
that's suppose to return the auto complete results. What could be
causing this in my project? No compilation error, other AJAX
components work fine. Could be something in web.config file? I've
included my code below
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="Test_Default" %>
<%@ Register assembly="AjaxControlToolkit"
namespace="AjaxControlToolkit" tagprefix="ajaxtoolkit" %>
<!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>Test</title>
</head>
<body>
   <form id="form1" runat="server">
      <ajaxToolkit:ToolkitScriptManager runat="server"
ID="ScriptManager1" />
          <asp:TextBox runat="server" ID="myTextBox" Width="300"
autocomplete="off" />
           <ajaxToolkit:AutoCompleteExtender
               runat="server"
               BehaviorID="AutoCompleteEx"
               ID="autoComplete1"
               TargetControlID="myTextBox"
               ServicePath="AutoComplete.asmx"
               ServiceMethod="GetCompletionList"
               MinimumPrefixLength="1"
               CompletionInterval="100"
               EnableCaching="true"
               CompletionSetCount="20"
CompletionListCssClass="autocomplete_completionListElement"
               CompletionListItemCssClass="autocomplete_listItem"
CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem"
               DelimiterCharacters=";, :">
           </ajaxToolkit:AutoCompleteExtender>
   </form>
</body>
</html>
In my AutoComplete.asmx
<%@ WebService
   Language="C#"
   CodeBehind="/App_Code/AutoComplete.cs"
   Class="AutoComplete" %>
In App_Code folder AutoComplete.cs
using System;
using System.Collections.Generic;
using System.Web.Services;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class AutoComplete : WebService
{
   public AutoComplete()
   {
   }
   [WebMethod]
   public string[] GetCompletionList(string prefixText, int count)
   {
       if (count == 0)
       {
           count = 10;
       }
       if (prefixText.Equals("xyz"))
       {
           return new string[0];
       }
       Random random = new Random();
       List<string> items = new List<string>(count);
       for (int i = 0; i < count; i++)
       {
           char c1 = (char)random.Next(65, 90);
           char c2 = (char)random.Next(97, 122);
           char c3 = (char)random.Next(97, 122);
           items.Add(prefixText + c1 + c2 + c3);
       }
       return items.ToArray();
   }
}
Thank you
Maz- Hide quoted text -

- Show quoted text -

Yes.. the 2 web.config files are extactly identical...

Any idea? anyone else?

Thx
Maz
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top