Hi,
Here is a definition for the context:
context
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.
Here is an example on how to use it:
In Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function ReceiveServerData(arg, context)
{
Arg1.innerText = "arg = " + arg;
Arg2.innerText = "context = " + context;
}
function context(value)
{
return "client " + value;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" value="CallBack"
onclick="CallServer('input1', context('input1'))"/>
<br />
<span id="Arg1"></span>
<br />
<span id="Arg2"></span>
</div>
</form>
</body>
</html>
and in Default.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
private string aStringValue;
protected void Page_Load(object sender, EventArgs e)
{
ClientScriptManager cm = Page.ClientScript;
String cbReference = cm.GetCallbackEventReference(this, "arg",
"ReceiveServerData", "context");
String callbackScript = "function CallServer(arg, context) {" +
cbReference + "; }";
cm.RegisterClientScriptBlock(this.GetType(),
"CallServer", callbackScript, true);
}
#region ICallbackEventHandler Members
public string GetCallbackResult()
{
return aStringValue;
}
public void RaiseCallbackEvent(string eventArgument)
{
aStringValue = "server " + eventArgument;
}
#endregion
}
Note the main point here is context(value) get called on the client side and the result is passed back to the client-side event handler ReceiveServerData(arg, context).
I hope this helps,
Barry