views:

1340

answers:

4

Ok, so my method in my webservice requires a type to be passed, it is called in the ServiceMethod property of the AutoCompleteExtender, I am fuzzy about how I should do that so I called it like this:

ServiceMethod="DropDownLoad<<%=(typeof)subCategory%>>"

where subCategory is a page property that looks like this:

protected SubCategory subCategory
    {
        get
        {
            var subCategory = NHibernateObjectHelper.LoadDataObject<SubCategory>(Convert.ToInt32(Request.QueryString["SCID"]));
            return subCategory;
        }
    }
+1  A: 

I dont' think calling a Generic Method on a webservice is possible.

If you look at the service description of two identical methods, one generic, one not:

[WebMethod]
public string[] GetSearchList(string prefixText, int count)
{
}

[WebMethod]
public string[] GetSearchList2<T>(string prefixText, int count)
{
}

They are identical. It appears that both SOAP 1.x and HTTP POST do not allow this type of operation.

bentford
A: 

TThank you for your help. Is there a way to change the number of parameters the AutoCompleteExtender sends?

Or do you have a suggestion as how to be able to have one web method to populate different drop downs based on the type of data bound?

Maybe I'm over refactoring, it would just make life easier.

Thank you.

Sara Chipps
+2  A: 

You could use the AutoCompleteExtender's ContextKey parameter to use a single web method that accepted a type name as its context key. Then in the web method, use reflection and that parameter to return the desired string[].

Dave Ward
A: 

Thank you Dave... I feel like a refactoring superhero, lol.

Sara Chipps