我正在研究PageMethods。几乎我都有PageMethods提出的所有问题。但我无法将dropdownlist的id作为参数传递。以下是我的javascript和webmethod
使用Javascript:
var ddlpf=document.getElementById('<%=ddlpf.ClientID%>');
PageMethods.updateDrop(ddlpf, "select_portfolio", para, "pfname", "pfid", true, "--Select--",OnSucess,OnFail);
的WebMethod:
<WebMethod()> _
<ScriptMethod()> _
Public Shared Function updateDrop(ByVal cboname As DropDownList, ByVal spname As String, ByVal para1 As Object, ByVal dismem As String, ByVal valmem As String, ByVal wsel As Boolean, ByVal wseltext1 As String) As Boolean
loadcombo(cboname, spname, para1, dismem, valmem, wsel, wseltext1)
Return True
End Function
它不起作用。任何人都可以指导我实现这个目标吗?
答案 0 :(得分:1)
首先,您必须从Web方法返回一个数组。然后将其更新为下拉列表。
PageMethods.updateDrop("select_portfolio", para, "pfname", "pfid", true, "--Select--",'a',false,null,OnSuccess,OnFail);
function OnSuccess(response)
{
ddlpf.options.length=0;
for(i=0;i<response.length;i=i+2)
{
var ddloption=new Option(response[i],response[i+1]);
ddlpf.options.add(ddloption);
}
}
function onFail(){}