1

好的,所以我的 web 服务中的方法需要传递一个类型,它在 AutoCompleteExtender 的 ServiceMethod 属性中调用,我不知道该怎么做,所以我这样称呼它:

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

其中 subCategory 是一个页面属性,如下所示:

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

2 回答 2

2

您可以使用 AutoCompleteExtender 的 ContextKey 参数来使用接受类型名称作为其上下文键的单个 Web 方法。然后在 web 方法中,使用反射和该参数返回所需的字符串 []。

于 2008-09-04T23:49:13.887 回答
1

我不认为在 web 服务上调用通用方法是可能的。

如果您查看两种相同方法的服务描述,一种是通用的,一种不是:

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

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

它们是相同的。似乎 SOAP 1.x 和 HTTP POST 都不允许这种类型的操作。

于 2008-09-04T22:52:28.407 回答