Sunday, March 11, 2012

Passing multiple parameters?

Yes , the webmethod can have more than one parameter. (see changes in bold)

griff303:

.ASPX page - javascript

function OnTextChange()
{
ret = ZipWebService.GetZipCodeInformation(document.getElementById('zipCode').value, newParameter, OnComplete, OnTimeOut, OnError);
return (true);
}

.

.

.

.ASMX page

Public Function GetZipCodeInformation(ByVal zip As String, ByVal newParameter As String) As String

... perform a db call

End Function


Ok... Now they have changed it to a checkbox list in where i have to pass all the values that are selected. I have tried passing all the values meshed together, but even that doesn't work right. I get the javascript error 'Object doesn't support this property or method' at bolded javascript IF.

Entry.aspx

function OnTextChange()
{
//productCB_0
var checkBoxList;

for (i = 0; i < 1; i++)
{
if (document.getElementByID("productCB_" + i ).checked)
{
checkBoxList += document.getElementByID("productCB_" + i).value;
}

}

ZipWebService.GetZipCodeInformation(document.getElementById('zipCode').value, checkBoxList.value, OnComplete, OnTimeOut, OnError);
return (true);
}

function OnComplete(arg)
{
alert(arg);
}

function OnTimeOut(arg)
{
alert("Timed out");
}

function OnError(arg)
{
alert("Errored out");
}


html

<td><asp:CheckBoxList ID="productCB" CssClass="slim" runat="server"></asp:CheckBoxList></td>

WebService.aspx

Public Function GetZipCodeInformation(ByVal zip As String, ByVal product As String) As String

No comments:

Post a Comment