Hopefully this is what you are looking for...
public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
{
protected string returnValue;
protected void Page_Load(object sender, EventArgs e)
{
string cbReference =
Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
string callbackScript = "function CallServer(arg, context) { " + cbReference + ";}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
}
public void RaiseCallbackEvent(string eventArgument)
{
if (eventArgument == "113")
{
returnValue = "F2 Was Pressed";
}
else
{
returnValue = "Some Other Key Was Pressed";
}
}
public string GetCallbackResult()
{
return returnValue;
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<script language="javascript">
function txtSearch_onkeyup() {
document.getElementById("ResultsSpan").innerHTML = "";
if (window.event.keyCode) {
CallServer(window.event.keyCode, "");
}
}
function ReceiveServerData(rValue) {
document.getElementById("ResultsSpan").innerHTML = rValue;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtSearch" NAME="txtSearch" runat="server" onkeyup="javascript:txtSearch_onkeyup()"></asp:TextBox>
<br />
<span id="ResultsSpan" runat="server"></span>
</div>
</form>
</body>
</html>
Enjoy,
Ashish Mehta