views:

103

answers:

1

I'm using the auto complete control here:http://www.ramirezcobos.com/labs/autocomplete-for-jquery-js/comment-page-2/

And i've modified it as:

        var json_options;
        json_options = {
        script:'ReportSearch.aspx/GetUserList?json=true&limit=6&',
        varname:'input',
        json:true,
        shownoresults:true,
        maxresults:16,
        callback: function (obj) { $('#json_info').html('you have selected: '+obj.id + ' ' + obj.value + ' (' + obj.info + ')'); }
    };

$('#ctl00_contentModule_txtJQuerySearch').autoComplete(json_options);

I have the following method in C# Code behind (aspx.cs)

    [System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static string[] GetUserList(string input)
{
    List<string> lUsers = new List<string>();

    Server.DAL.SQLServer2005.User user = new Server.DAL.SQLServer2005.User();
    Server.Info.AuthUser aUser = (Server.Info.AuthUser)HttpContext.Current.Session["AuthUser"];
    List<Server.Info.User.UserDetails> users = user.GetUserList(aUser, input, 16, true);
    users.ForEach(delegate(ReportBeam.Server.Info.User.UserDetails u)
    {
        lUsers.Add("(" + u.UserName + ")" + u.LastName + ", " + u.FirstName);
    });
    return lUsers.ToArray();
}

The error I get back is:

Server Error in '/WebPortal4' Application. Unknown web method GetUserList. Parameter name: methodName

If I change any of the paraemeter names I get an error telling me the paremeter names are not in match. now that everything is as it should, it's bombing.

Any help would rock.

+1  A: 

If your code is in a user control, (and not in the actual aspx), that might cause problems. I guess it shouldn't, but I've had problems with it myself, don't remember exactly how they looked, but in the end I retorted to placing my web methods in asmx files instead of aspx files, if they are to be reached from anything but the aspx itself, and it's been working out great =)

David Hedlund
I guess I could try that, and enable sessions in the asmx file.
Ryan Ternier
you can't access webmethod/pagemethod in user controls, they have to be in the parent aspx or a webservice ascx.
Matt
@Matt: I've been happy with the asmx solution, so I've never really pursued the reason as to why I didn't get it working, but that's great to have a satisfying answer, then =) Cheers
David Hedlund