C# Ajax自动完成Web服务调用-服务方法,我调用这个方法正确吗?
好的,我的webservice中的方法需要传递一个类型,它在AutoCompleteXtender的ServiceMethod属性中调用,我不清楚该如何做,所以我这样调用它:C# Ajax自动完成Web服务调用-服务方法,我调用这个方法正确吗?,c#,asp.net,asp.net-ajax,C#,Asp.net,Asp.net Ajax,好的,我的webservice中的方法需要传递一个类型,它在AutoCompleteXtender的ServiceMethod属性中调用,我不清楚该如何做,所以我这样调用它: ServiceMethod="DropDownLoad<<%=(typeof)subCategory%>>" protected SubCategory subCategory { get { var subCategory = NHibernateObjectHe
ServiceMethod="DropDownLoad<<%=(typeof)subCategory%>>"
protected SubCategory subCategory
{
get
{
var subCategory = NHibernateObjectHelper.LoadDataObject<SubCategory>(Convert.ToInt32(Request.QueryString["SCID"]));
return subCategory;
}
}
ServiceMethod=“DropDownLoad”
其中subCategory是一个页面属性,如下所示:
ServiceMethod="DropDownLoad<<%=(typeof)subCategory%>>"
protected SubCategory subCategory
{
get
{
var subCategory = NHibernateObjectHelper.LoadDataObject<SubCategory>(Convert.ToInt32(Request.QueryString["SCID"]));
return subCategory;
}
}
受保护子类别子类别
{
得到
{
var subCategory=NHibernateObjectHelper.LoadDataObject(Convert.ToInt32(Request.QueryString[“SCID]”));
返回子类别;
}
}
我认为在Web服务上调用通用方法是不可能的
如果查看两个相同方法的服务描述,一个是泛型,一个不是:
[WebMethod]
public string[] GetSearchList(string prefixText, int count)
{
}
[WebMethod]
public string[] GetSearchList2<T>(string prefixText, int count)
{
}
[WebMethod]
公共字符串[]GetSearchList(字符串前缀文本,整数计数)
{
}
[网络方法]
公共字符串[]GetSearchList2(字符串前缀,整数计数)
{
}
它们是相同的。SOAP 1.x和HTTP POST似乎都不允许这种类型的操作。您可以使用AutoCompleteXtender的ContextKey参数来使用接受类型名称作为其上下文键的单个web方法。然后在web方法中,使用反射和该参数返回所需的字符串[]