I have done a ton of research in this area and there just does not seem to be a way to pass any addiional parameters to the Web Service reference in the autoextneder call. Is there a way that this can be done. In my world, the list of suggestion is dependant on other data on my web form or web user control. I had read some references that you might be able to call a method in the code behind page, however everything i have tried on this has failed. Here is a list of what I have attempted
Tried to add query string arguments to the service path property (error is thrown trying to render the page)
Tried to set the service path to a web page (aspx) and then call the code behind method (this also threw error trying to render the page)
Viewed some alternative solutions from vrious posts...however most we out of date t the current release (RC1).
I see that David Reed has an example at Infiinity Loop, however his server is unavailable at this time.
I would love for the auto extender to be able to natively support calling the code behind method of the page or user control that is using it. It would seem logical that the derived suggestion should be able to present a filtered list based on other data. It would be nice if I could pass it an array of string that represent name value pairs of data that I can then access in the web service and pass to whatever is building the list. Anyway just a suggestion...maybe the functionality is there and I just can not figure it out
Please help
>> I have done a ton of research in this area and there just does not seem to be a way to pass any addiional parameters to the Web Service reference in the autoextneder call. Is there a way that this can be done. In my world, the list of suggestion is dependant on other data on my web form or web user control.
With some digging around in the AutoCompleteExtender you may be able to modify the javascript to do this - I've never looked at it personally but that is where I would start. You would need to hijack that part that reads from the target control and add other data to the call.
>> I had read some references that you might be able to call a method in the code behind page, however everything i have tried on this has failed.
The following RC1 example of using a page method works on my system, but it's not going to solve your problem. The page method has to be static, so you won't be able to access any form data.
<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %><%@. Register Assembly="BenValidationControls" Namespace="ben" TagPrefix="hauna" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><script runat="server"> [System.Web.Script.Services.ScriptMethod] [System.Web.Services.WebMethod] public static string[] AutoCompleteMethod(String prefixText, int count) { return new string[] { "foo", "baz" }; } </script><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> <div> <asp:TextBox ID="TextBox1" runat="server" /> <asp:AutoCompleteExtender ID="AutoCompleteExtender1" ServiceMethod="AutoCompleteMethod" ServicePath="~/default.aspx" TargetControlID="TextBox1" MinimumPrefixLength="1" runat="server" /> </div> </form></body></html>Thanks for the response. I am looking at modifying from the jvavascript as you have suggested. Here is also what I have found out...
First off the code behind must be in an aspx page and not in a ascx. I am not sure why that should matter but apparently it does. it would be really be nice if I could reference the code behind on either type of file. If you are trying to make a reusable control within your app with the auto complete extender then this is somewhat limiting. Also what I did not know or see document anywhere that this function needed to be static. Once I did that it started working quite well.
Thank you very much on this. This actually helped quite a bit.
You were referring to my derived AutoCompleteExtender that enables callbacks... I had some server issues but its back up and running :) This would solve your problem perfectly.
http://weblogs.asp.net/infinitiesloop/archive/2006/11/15/ASP.NET-Ajax-Beta_3A00_-AutoCompleteBehavior-without-a-Web-Service.aspx
No comments:
Post a Comment