trouble calling a webmethod

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff

    trouble calling a webmethod

    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 GetCompletionLi st takes 2
    parameters. I don't set the value of these input parameters.

    [WebMethod]
    Car: <asp:TextBox ID="txtCar" runat="server"> </asp:TextBox>
    <cc1:AutoComple teExtender ID="AutoComplet eExtender1"
    runat="server"
    TargetControlID ="txtCar"
    ServicePath="~/Services/AutoCompleteWeb Site.asmx"
    ServiceMethod=" GetCompletionLi st"
    MinimumPrefixLe ngth="3" CompletionSetCo unt="10" >
    </cc1:AutoComplet eExtender>


    public List<stringGetC ompletionList(s tring prefix, int count)
    {
    List<stringcars = Car.GetCarsColl ection(prefix, count);
    List<stringname s = null;
    foreach (Car car in cars)
    {
    names.Add(car.U rl);
    }
    return names;
    }

    any suggestions why my code isn't executed


  • George

    #2
    Re: trouble calling a webmethod

    The WebMethod must be declared as static...

    George.

    "Jeff" <it_consultant1 @hotmail.com.NO SPAMwrote in message
    news:eoh8Ei0SJH A.5344@TK2MSFTN GP06.phx.gbl...
    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 GetCompletionLi st takes
    2 parameters. I don't set the value of these input parameters.
    >
    [WebMethod]
    Car: <asp:TextBox ID="txtCar" runat="server"> </asp:TextBox>
    <cc1:AutoComple teExtender ID="AutoComplet eExtender1"
    runat="server"
    TargetControlID ="txtCar"
    ServicePath="~/Services/AutoCompleteWeb Site.asmx"
    ServiceMethod=" GetCompletionLi st"
    MinimumPrefixLe ngth="3" CompletionSetCo unt="10" >
    </cc1:AutoComplet eExtender>
    >
    >
    public List<stringGetC ompletionList(s tring prefix, int count)
    {
    List<stringcars = Car.GetCarsColl ection(prefix, count);
    List<stringname s = null;
    foreach (Car car in cars)
    {
    names.Add(car.U rl);
    }
    return names;
    }
    >
    any suggestions why my code isn't executed
    >

    Comment

    • Jeff

      #3
      Re: trouble calling a webmethod

      you mean like this:

      [WebMethod]
      public static List<stringGetC ompletionList(s tring prefix, int count)
      {
      List<stringcars = Car.GetCarsColl ection(prefix, count);
      List<stringname s = null;
      foreach (Car car in cars)
      {
      names.Add(car.U rl);
      }
      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
      GetCompletionLi st... not sure how to specify them




      "Jeff" <it_consultant1 @hotmail.com.NO SPAMwrote in message
      news:eoh8Ei0SJH A.5344@TK2MSFTN GP06.phx.gbl...
      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 GetCompletionLi st takes
      2 parameters. I don't set the value of these input parameters.
      >
      [WebMethod]
      Car: <asp:TextBox ID="txtCar" runat="server"> </asp:TextBox>
      <cc1:AutoComple teExtender ID="AutoComplet eExtender1"
      runat="server"
      TargetControlID ="txtCar"
      ServicePath="~/Services/AutoCompleteWeb Site.asmx"
      ServiceMethod=" GetCompletionLi st"
      MinimumPrefixLe ngth="3" CompletionSetCo unt="10" >
      </cc1:AutoComplet eExtender>
      >
      >
      public List<stringGetC ompletionList(s tring prefix, int count)
      {
      List<stringcars = Car.GetCarsColl ection(prefix, count);
      List<stringname s = null;
      foreach (Car car in cars)
      {
      names.Add(car.U rl);
      }
      return names;
      }
      >
      any suggestions why my code isn't executed
      >

      Comment

      • George

        #4
        Re: trouble calling a webmethod

        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 AutoCompleteWeb Site.asmx where you
        define this GetCompletionLi st 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" <it_consultant1 @hotmail.com.NO SPAMwrote in message
        news:OepHtG1SJH A.3880@TK2MSFTN GP04.phx.gbl...
        you mean like this:
        >
        [WebMethod]
        public static List<stringGetC ompletionList(s tring prefix, int count)
        {
        List<stringcars = Car.GetCarsColl ection(prefix, count);
        List<stringname s = null;
        foreach (Car car in cars)
        {
        names.Add(car.U rl);
        }
        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
        GetCompletionLi st... not sure how to specify them
        >
        >
        >
        >
        "Jeff" <it_consultant1 @hotmail.com.NO SPAMwrote in message
        news:eoh8Ei0SJH A.5344@TK2MSFTN GP06.phx.gbl...
        >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 GetCompletionLi st
        >takes 2 parameters. I don't set the value of these input parameters.
        >>
        >[WebMethod]
        >Car: <asp:TextBox ID="txtCar" runat="server"> </asp:TextBox>
        > <cc1:AutoComple teExtender ID="AutoComplet eExtender1"
        > runat="server"
        > TargetControlID ="txtCar"
        > ServicePath="~/Services/AutoCompleteWeb Site.asmx"
        > ServiceMethod=" GetCompletionLi st"
        > MinimumPrefixLe ngth="3" CompletionSetCo unt="10" >
        > </cc1:AutoComplet eExtender>
        >>
        >>
        >public List<stringGetC ompletionList(s tring prefix, int count)
        > {
        > List<stringcars = Car.GetCarsColl ection(prefix, count);
        > List<stringname s = null;
        > foreach (Car car in cars)
        > {
        > names.Add(car.U rl);
        > }
        > return names;
        > }
        >>
        >any suggestions why my code isn't executed
        >>
        >
        >

        Comment

        • Jeff

          #5
          Re: trouble calling a webmethod

          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 GetCompletionLi st method. That method takes 2 parameters,
          but I don't know where they are set.

          any ideas how those parameters are specified?


          Comment

          • George

            #6
            Re: trouble calling a webmethod

            They have a download C# right next to the video link
            Just download the code

            George.

            "Jeff" <it_consultant1 @hotmail.com.NO SPAMwrote in message
            news:ewW3zT2SJH A.588@TK2MSFTNG P06.phx.gbl...
            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 GetCompletionLi st method. That method takes 2
            parameters, but I don't know where they are set.
            >
            any ideas how those parameters are specified?
            >

            Comment

            Working...