Click here to Skip to main content
15,884,099 members
Articles / Web Development / ASP.NET
Tip/Trick

Passing parameters to Success method in executeQueryAsync in SharePoint

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
21 Aug 2013CPOL 46.3K   2   1
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)


Written By
Technical Lead Softedge Systems LTD
Ireland Ireland
 Experienced software professional with 7 years+ on Microsoft Technology.
 Knowledge of SDLC (System Development Life Cycle).
 Technical Team Member experience leading application development on both short and long term projects.
 Good team player with excellent work history as regards with work ethics, dependability and willingness to go an extra mile.
 Good knowledge of IIS Hosting and Domain management.
 Extensive knowledge of ASP.Net, C#.Net, VB.Net, SQL Server, SharePoint development using SharePoint Web Services and SharePoint administration, Business Intelligence & KPIs (Configuration and Creation) Web Parts, Data View Webparts, Integration of External Sources content types, Site Definition, Site templates, Workflow development, customizing and branding a SharePoint portal sites and branding.

Comments and Discussions

 
QuestionPassing Parameters to Success method in executeQueryAsync SharePoint - Original Pin
Isha Attlee28-Aug-13 15:14
Isha Attlee28-Aug-13 15:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.