<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>WEb Service CallBack</title>
<script type="text/javascript">
function GetTemp() {
var zipcode = document.forms[0].TextBox1.value;
UseCallback(zipcode, "");
}
function GetTempFromServer(TextBox2, context) {
document.forms[0].TextBox2.value = "Zipcode: " +
document.forms[0].TextBox1.value + " | Temp: " + TextBox2;
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
<input id="Button1" type="button" value="Get Temp" onclick="GetTemp()" />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />
</div>
</form>
</body>
</html>
=====================================================================================
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SingleParam : System.Web.UI.Page, System.Web.UI.ICallbackEventHandler
{
private string _callbackResult = null;
protected void Page_Load(object sender, EventArgs e)
{
string cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "GetTempFromServer", "context");
string cbScript = "function UseCallback(arg, context)" + "{" + cbReference + ";" + "}";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "UseCallback", cbScript, true);
}
public void RaiseCallbackEvent(string eventArg)
{
_callbackResult = "zzzzzzzzzzzzzz";
}
public string GetCallbackResult()
{
return _callbackResult;
}
}