Re: AJAX - AutoCompleteExtender ASP.Net 2.0 (Page Method vs. Web S



Hello Henning,

Thank you so much for your dedicated help on this issue. I had added the
new web.config segment of <httpHandlers> but hadn't added <httpModules>.
Once I added that, it started working like a champ for me as well :)

Thanks again,

Trent

"Henning Krause [MVP - Exchange]" wrote:

Hello,

works like charm here.

Here is the complete source:

Default.aspx.cs:

[WebMethod]
[ScriptMethod]
public static string[] GetTextBoxEntries(string prefixText, int
count)
{
string[] result;
result = new string[4];
result[0] = prefixText + "AAAAAAAA";
result[1] = prefixText + "DDDDDDDD";
result[2] = prefixText + "MMMMMMMM";
result[3] = prefixText + "VVVVVVVV";
return result;
}

======================

UserControl.ascx:

<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePartialRendering="true" EnablePageMethods="true" />
<asp:TextBox runat="server" ID="tbTextBox" />
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
ServiceMethod="GetTextBoxEntries" TargetControlID="tbTextBox"
CompletionSetCount="10" MinimumPrefixLength="1" EnableCaching="true" />


Changes in the web.config:

<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI"
assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit"
namespace="AjaxControlToolkit" />
</controls>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false"
type="System.Web.Script.Services.ScriptHandlerFactory,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd"
type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions,
Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false"/>
</httpHandlers>

<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule,
System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>

Best regards,
Henning Krause


"Trent" <Trent@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7A87C71E-5B9B-4623-BFE2-AC5C55DCB2D9@xxxxxxxxxxxxxxxx
Here is my code.

**********pagename.ascx
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true">

</asp:ScriptManager>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
TargetControlID="txtDestination"
CompletionSetCount="10"
MinimumPrefixLength="1"
EnableCaching="true"
ServiceMethod="GetDest"/>

**********pagename.aspx.cs
[WebMethod]
[ScriptMethod]
public static string[] GetDest(string prefixText, int count)
{

string[] result;
result = new string[4];
result[0] = prefixText + "AAAAAAAA";
result[1] = prefixText + "DDDDDDDD";
result[2] = prefixText + "MMMMMMMM";
result[3] = prefixText + "VVVVVVVV";
return result;
}

"Henning Krause [MVP - Exchange]" wrote:

Hello,

do you have enabled the property EnablePageMethods on the ScriptManager
in
your aspx file?

Best regards,
Henning Krause

"Trent" <Trent@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:587C2729-1DA3-44FB-9711-4B58E43F91BE@xxxxxxxxxxxxxxxx
Hi Henning,

I have downloaded the February 6 version of toolkit, removed the
toolkit
from the toolbox, re-added it, and removed the dll/pdb and readded the
reference as well. My codebehind is in pagename.aspx.cs, rather than
being
in pagename.ascx.cs. When I type into my textbox, a popup does appear
and
it
contains "undefined", "undefined", "undefined", "undefined",
"undefined"
which goes on and on seems like forever. If I set a breakpoint in the
"suggestion" codebehind method, it never breaks.

Thanks!

"Henning Krause [MVP - Exchange]" wrote:

Hello,

I've a working autocomplete extender using this schema:

In Codebehind:

[WebMethod]
[ScriptMethod]
public static string MyMethod(string contextKey)
{}

In aspx site:

<ajaxToolkit:AutoCompleteExtender runat="server"
ID="tbAutoCompleteExtender" TargetControlID="tbTextBox"

ServiceMethod="MyMethod"
MinimumPrefixLength="2" CompletionInterval="1000"

EnableCaching="true"
CompletionSetCount="12" />

Note that code-behind method must be in the .aspx file, even if the
autocomplete extender is in a usercontrol.

Do you have the latest version of the Ajax toolkit installed? It's
from
february... so only a few days old.

Best regards,
Henning Krause


"Trent" <Trent@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:F2F66216-BA07-4D81-B066-C98831BF1BB8@xxxxxxxxxxxxxxxx
I applied [ScriptMethod] immediately after [WebService] and that
didn't
fix
it. Any other thoughts? Thanks!

"Henning Krause [MVP - Exchange]" wrote:

Hello,

you'll have to specify the [ScriptMethod] attribute in addition to
the
[WebService] attribute.

Best regards,
Henning Krause

"Trent" <Trent@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:707AF9A7-9364-4976-9BD2-75312B84C1D0@xxxxxxxxxxxxxxxx
I have tied an AutoCompleteExtender to a textbox to indicate
suggestions
to
the user. Everything works fine if I utilize a webservice to
fetch
the
results. However, I want to put the web service code into a page
method.
I
have run the debugger only to find that the [WebMethod] is never
entered.
Here are some of the things I have already tried with no success.
It
appears
that this is a common problem.

-Added the [WebMethod] attribute to the top of the code-behind
method.
-Added/removed "Static" as part of the public method definition.
-Removed the "ServicePath" attribute from the
AutoCompleteExtender
.aspx
page.

My textbox and extender control are embedded into a user
control(.ascx)
that
is placed within a ContentPanel inherited from a MasterPage. I'm
not
sure
if
this could be part of the problem. As I view the browser source
code,
the
javascript renders the "ServicePath" to be looking by default at
my
aspx
page, but my [WebMethod] lives in pagename.ascx.cs. Also, I have
tried
including "ServicePath=pagename.ascx.cs" and still no luck.

At this point, I don't know what else to try. The main reason
I'm
wanting
to move to a page method is because I need access to controls
which
aren't
available to the web service. Also, I don't think my needs here
constitute
the need for a web service.

Any help would be greatly appreciated!

Thanks,

Trent








.



Relevant Pages

  • Re: AJAX - AutoCompleteExtender ASP.Net 2.0 (Page Method vs. Web S
    ... on the aspx side, I'm not sure how to access this value. ... [WebMethod] ... [ScriptMethod] ... public static string[] GetTextBoxEntries(string prefixText, ...
    (microsoft.public.dotnet.general)
  • Re: AJAX - AutoCompleteExtender ASP.Net 2.0 (Page Method vs. Web S
    ... [WebMethod] ... [ScriptMethod] ... In aspx site: ... I want to put the web service code into a page ...
    (microsoft.public.dotnet.general)
  • Re: AJAX - AutoCompleteExtender ASP.Net 2.0 (Page Method vs. Web S
    ... Best regards, ... In aspx site: ... you'll have to specify the [ScriptMethod] attribute in addition to the ... I want to put the web service code into a page ...
    (microsoft.public.dotnet.general)
  • Re: Cant find item in server side cache
    ... Then I used the url for web service when it was originally created which was ... So the web service and aspx ... page really were running in different instances of the web app. ... the web service returns the GUID back to the winform via the WS ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Cant find item in server side cache
    ... the aspx page was generated in a different instance of the web app from the ... instance the web service was running in (although they are part of the same ... web app). ... the winform calls a web service which generates a GUID and puts it into ...
    (microsoft.public.dotnet.framework.aspnet)