Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Passing parameters to Success method in executeQueryAsync in SharePoint

5.00/5 (2 votes)
21 Aug 2013CPOL 46.9K  
Passing Parameters to Success method in executeQueryAsync.

Introduction

This is quick tip about how to pass parameters and retrieve values from the Success method in executeQueryAsync().

To pass a parameter in Success method use the following syntax:

Before passing parameters:

C#
context.executeQueryAsync(Function.createDelegate(this,this.success)),
 Function.createDelegate(this, this.failed));

After passing parameters:

C#
context.executeQueryAsync(
Function.createDelegate(this,function(){success(_parameter);}),
Function.createDelegate(this, this.failed));
function success(_parameter)
{
    alert("In Success Method! " + _parameter);
}

To retrieve values from Success method use the following syntax:

C#
context.executeQueryAsync(
Function.createDelegate(thisfunction(){ _returnParam = success(_parameter);}),
Function.createDelegate (this, this.failed));
alert(_returnParam);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)