遇到个辣手的问题, 为什么不能够使用Asp.net 2.0的客户端回调功能
代码如下:
1. 前台
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Client-Side Callback </title>
<script type= "text/javascript ">
function GetNumber()
{
UseCallBack( 'abc ', 'context ');
}
function GetRandomNumberFromServer(result, context)
{
document.forms[0].TextBox1.value = result;
}
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<input id= "Button1 " type= "button " value= "button " onclick= "GetNumber() " />
<br />
<br />
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox> </div>
</form>
</body>
</html>
2. 后台
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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 Default2 : System.Web.UI.Page, ICallbackEventHandler
{
private string _callbackResult = null;
protected void Page_Load(object sender, EventArgs e)
{
string cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg ", "GetRandomNumberFromServer ", "context ");
string cbScript = "function UseCallBack(arg, context) " + "{ " + cbReference + "; " + "} ";