How can I retrieve values from a Webmethod and format them in JSON for the client?
I have two static int values that need to be returned. Do I have to create a new object with these properties each time, or is there a more efficient way to handle this? The GetStatus() method is called frequently, and creating a new object for JSON formatting seems cumbersome...
[WebMethod]
public static int GetStatus()
{
int statusProcess,statusProcessTotal;
Status.Lock.EnterReadLock();
statusProcess=Status.Process; //Static field
statusProcessTotal=Status.ProcessTotal; //Static field
Status.Lock.ExitReadLock();
return ...
}
On the client side, the return value is captured using:
function OnSucceeded(result, userContext, methodName)
(PageMethods.GetStatus(OnSucceeded, OnFailed);)