trouble calling a webmethod

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hi

asp.net 2.0

The webmethod below don't get called. I'm not sure what I do wrong here. I
think it's something to with the parameters. The GetCompletionList takes 2
parameters. I don't set the value of these input parameters.

[WebMethod]
Car: <asp:TextBox ID="txtCar" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1"
runat="server"
TargetControlID="txtCar"
ServicePath="~/Services/AutoCompleteWebSite.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="3" CompletionSetCount="10" >
</cc1:AutoCompleteExtender>


public List<string> GetCompletionList(string prefix, int count)
{
List<string> cars = Car.GetCarsCollection(prefix, count);
List<string> names = null;
foreach (Car car in cars)
{
names.Add(car.Url);
}
return names;
}

any suggestions why my code isn't executed
 
you mean like this:

[WebMethod]
public static List<string> GetCompletionList(string prefix, int count)
{
List<string> cars = Car.GetCarsCollection(prefix, count);
List<string> names = null;
foreach (Car car in cars)
{
names.Add(car.Url);
}
return names;
}

I've tryed this but the code didn't execute. I wonder if that is because I
haven't specified the values of the input parameters of the
GetCompletionList... not sure how to specify them
 
I am sorry i did not notice that you using it as a Service and not WebMethod
on page.
Then it does not need to be static.

So you have in your project root file AutoCompleteWebSite.asmx where you
define this GetCompletionList function.

There is a video http://www.asp.net/learn/ajax-videos/video-122.aspx on how
to do it as well as C# code..
Check it out.


George.


Jeff said:
you mean like this:

[WebMethod]
public static List<string> GetCompletionList(string prefix, int count)
{
List<string> cars = Car.GetCarsCollection(prefix, count);
List<string> names = null;
foreach (Car car in cars)
{
names.Add(car.Url);
}
return names;
}

I've tryed this but the code didn't execute. I wonder if that is because I
haven't specified the values of the input parameters of the
GetCompletionList... not sure how to specify them




Jeff said:
hi

asp.net 2.0

The webmethod below don't get called. I'm not sure what I do wrong here.
I think it's something to with the parameters. The GetCompletionList
takes 2 parameters. I don't set the value of these input parameters.

[WebMethod]
Car: <asp:TextBox ID="txtCar" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1"
runat="server"
TargetControlID="txtCar"
ServicePath="~/Services/AutoCompleteWebSite.asmx"
ServiceMethod="GetCompletionList"
MinimumPrefixLength="3" CompletionSetCount="10" >
</cc1:AutoCompleteExtender>


public List<string> GetCompletionList(string prefix, int count)
{
List<string> cars = Car.GetCarsCollection(prefix, count);
List<string> names = null;
foreach (Car car in cars)
{
names.Add(car.Url);
}
return names;
}

any suggestions why my code isn't executed
 
Yeah I've been watching that video a few times already today. It is that
video I've based my code on. I still don't understand how he pass
paramerters to the GetCompletionList method. That method takes 2 parameters,
but I don't know where they are set.

any ideas how those parameters are specified?
 
Back
Top