Question

I am now working on PageMethods. Almost I have all the problems raised by PageMethods. But I couldnot pass dropdownlist's id as a parameter. The following is my javascript and 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

It is not working. Can anyone guide me to achieve this?

Was it helpful?

Solution

First you have to return an array from the web method. then update it to the dropdown.

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(){}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top