how to use CallbackEventHandler, the example
<%@ Page Language="C#" %>
<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>
<!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 runat="server" >
string result = string.Empty;
// Define method that processes the callbacks on server.
//receive the argument transfered from client-side
public void RaiseCallbackEvent(String eventArgument)
{
result = eventArgument + " and more";
}
// Define method that returns callback result.
// return the result to the client-side function which is specified in the GetCallbackEventReference
public string GetCallbackResult()
{
return result;
}
</script>
<script language="javascript" type="text/javascript">
// the <% %> code will becomes a js function when the page is displayed at the browser.
function jscall(arg,context)
{
<%= Page.ClientScript.GetCallbackEventReference(this, "arg", "receiveFunction", "context")%>;
}
// result from the server-side is passed to the "result" argument
function receiveFunction(result,context)
{
form1.test.value=result ;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<input name="test" value=’I love kerry more’ size="100"/>
<input type="button" value="call" onclick="jscall(form1.test.value,’none’)" />
</form>
</body>
</html>
