开发者

WebForm_DoCallback definition

Is there a simple explanation on MSDN of WebForm_DoCallback function?

All I can find is this article http://msdn.mic开发者_如何转开发rosoft.com/en-us/magazine/cc163878.aspx which does include implementation of WebForm_DoCallback but doesn't do a good job explaining parameters themselves.

function WebForm_DoCallback(eventTarget, eventArgument, 
eventCallback, context, errorCallback) 

Like what exactly does it expect as an 'eventTarget'? What is 'context'? Etc...


WebForm_DoCallback appears to be the client-side counterpart to GetCallbackEventReference. It's generated with the same arguments, which are as follows:

target: The name of a server Control that handles the client callback. The control must implement the ICallbackEventHandler interface and provide a RaiseCallbackEvent method.

argument: An argument passed from the client script to the server RaiseCallbackEvent method.

clientCallback: The name of the client event handler that receives the result of the successful server event.

context: Client script that is evaluated on the client prior to initiating the callback. The result of the script is passed back to the client event handler.

clientErrorCallback: The name of the client event handler that receives the result when an error occurs in the server event handler.

useAsync: true to perform the callback asynchronously; false to perform the callback synchronously.

clientCallback and clientErrorCallback are client-side (usually javascript) functions with arguments in the form:

function clientCallback(returnmessage, context) {}

Where returnmessage is the response from the server (or error) and context is the same as the context passed in previously.

References:

MSDN: ClientScriptManager.GetCallbackEventReference Method

MSDN Magazine: Implications of Script Callbacks in ASP.NET

ESRI Developer Network: Page Postbacks and Client Callbacks


we can see something like this--

WebForm_DoCallback('__Page',parameter,callBack,context,null,false);

in the page resource file. it seems the 'parameter' is a value type(string), while the context is a ref type. anyway the "context" is rarely used. the "Parameter" could only be a string, so you may need combine several values into it, and then separate it on the server. while the data is transmitted to the server end, the relative class(as a subclass of interface 'ICallbackEventHandler') instant will be created, and the handler method will be called:

public void RaiseCallbackEvent(string eventArgument)
{
   //deal with the eventArgument( the "parameter")        
}

after that another method goes on and return a string back in the response..

public string GetCallbackResult()
{
    //return command;
}

finally the async process raises the callback function( "callBack" in this case),which should has 2 input params:

function callBack(returnedStuff, context) {......}

and that's how it works however I don't know where the javascript function "WebForm_DoCallback" is defined, so it may not work on the non-windows computers.


To what context do you need to use this with? The string is generated by the following method call in ClientScriptManager: http://msdn.microsoft.com/en-us/library/ms153110%28v=VS.100%29.aspx

Using this is what you can use to produce the above statement, without having to know the details.

HTH.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜