What is a callback?

前端 未结 11 1426
鱼传尺愫
鱼传尺愫 2020-11-28 00:57

What\'s a callback and how is it implemented in C#?

11条回答
  •  生来不讨喜
    2020-11-28 01:06

    callback work steps:

    1) we have to implement ICallbackEventHandler Interface

    2) Register the client script :

     String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
        String callbackScript = "function UseCallBack(arg, context)" + "{ " + cbReference + ";}";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "UseCallBack", callbackScript, true);
    

    1) from UI call Onclient click call javascript function for EX:- builpopup(p1,p2,p3...)

    var finalfield= p1,p2,p3; UseCallBack(finalfield, ""); data from the client passed to server side by using UseCallBack

    2) public void RaiseCallbackEvent(string eventArgument) In eventArgument we get the passed data //do some server side operation and passed to "callbackResult"

    3) GetCallbackResult() // using this method data will be passed to client(ReceiveServerData() function) side

    callbackResult

    4) Get the data at client side: ReceiveServerData(text) , in text server response , we wil get.

提交回复
热议问题