Quickie: definition of "context"?

R

Roy

From the MS site:
NAME: ClientScriptManager.GetCallbackEventReference (Control, String,
String, String)
DESCRIPTION: Obtains a reference to a client-side function that, when
invoked, initiates a client call back to a server-side event. The
client-side function for this overloaded method includes a specified
control, argument, client-side script, and context.

What is "context?"

Thanks
 
G

Guest

Roy,
the Documentation for GetCallBackEventReference describes all the parameters
and even provides code samples:

http://msdn2.microsoft.com/library/ms153106(en-us,vs.80).aspx

"Context" is the client-side script that is evaluated on the client prior to
initiating the callback. The result of the script is passed back to the
client-side event handler.

The example shows the creation (excerpt):

// Define one of the callback script's context.
// The callback script will be defined in a script block on the page.
StringBuilder context1 = new StringBuilder();
context1.Append("function ReceiveServerData1(arg, context)");
context1.Append("{");
context1.Append("Message1.innerText = arg;");
context1.Append("value1 = arg;");
context1.Append("}");

// Define callback references.
String cbReference1 = cs.GetCallbackEventReference(this, "arg",
"ReceiveServerData1", context1.ToString());
String cbReference2 = cs.GetCallbackEventReference("'" +
Page.UniqueID + "'", "arg", "ReceiveServerData2", "",
"ProcessCallBackError", false);
String callbackScript1 = "function CallTheServer1(arg, context) {" +
cbReference1 + "; }";
String callbackScript2 = "function CallTheServer2(arg, context) {" +
cbReference2 + "; }";

// Register script blocks will perform call to the server.
cs.RegisterClientScriptBlock(this.GetType(), "CallTheServer1",
callbackScript1, true);
cs.RegisterClientScriptBlock(this.GetType(), "CallTheServer2",
callbackScript2, true);

--Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top