关于public void RaiseCallbackEvent(string eventArgs)没被调用
各位高手,我下了个无刷新的东东,一开始有效果,后来不知道怎么地就无效果了,发现不执行public void RaiseCallbackEvent(string eventArgs),请问是怎么回事呢?先谢谢了。全部代码如下。
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 id="Head1" runat="server">
<title>无标题页</title>
<script type="text/javascript">
function FillData()
{
var city=document.getElementById("TextBox1").value;
<%= ClientScript.GetCallbackEventReference(this, "city", "fillDll", null,true)%>;
}
function fillDll(city)
{
document.getElementById("DropDownList1").options.length=0;
var indexofcity;
var city;
//切割传递来的字符串
while(city.length>0)
{
//判断是否是最后一个字符串
indexofcity=city.indexOf(",");
if(indexofcity >0)
{
city=city.substring(0,indexofcity);
city=city.substring(indexofcity+1);
//填充下拉框
document.getElementById("DropDownList1").add(new Option(city,city));
}
else
{
// 如果是最后一个字符串
document.getElementById("DropDownList1").add(new Option(city,city));
break;
}
};
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table style="width: 504px; height: 151px">
<tr>
<td colspan="2" style="font-weight: bold; color: #3300ff;">
使用回调技术实现局部刷新</td>
</tr>
<tr>
<td style="width: 135px">
输入城市名称</td>
<td style="width: 3px">
<asp:TextBox ID="TextBox1" runat="server" Width="233px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 135px">
</td>
<td style="width: 3px">
<input id="Button1" style="width: 131px" type="button" value="查询" onclick="FillData()"/></td>
</tr>
<tr>
<td style="width: 135px">
选择区域列表</td>
<td style="width: 3px">
<asp:DropDownList ID="DropDownList1" runat="server" Width="237px">
</asp:DropDownList></td>
</tr>
</table>
</div>
</form>
</body>
</html>
Default.aspx.cs
using System;
using System.Data;
using System.Web;
using System.Data.SqlClient;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Globalization;
using System.Web.UI;
using System.IO;
public partial class _Default : System.Web.UI.Page, ICallbackEventHandler
{
private string _data;
protected void Page_Load(object sender, EventArgs e)
{
}
#region ICallbackEventHandler 成员
public string GetCallbackResult()
{
//返回处理后的数据
return _data;
}
public void RaiseCallbackEvent(string eventArgs)
{
//判断传递过来的参数
switch (eventArgs)
{
case "北京":
_data = "朝阳,海淀,东城,西城";
break;
case "上海":
_data = "浦东,静安,徐汇,虹口";
break;
case "济南":
_data = "历城,历下,市中,天桥";
break;
}
}
#endregion
}