使用CallBack实现页面无刷新技术

页面的布局是由一个textbox控件和一个dropdownlist控件,让用户查询按钮时,实现调用查询事件的功能。 <script type="text/javascript"> //客户端调用回调事件的代码 function FillData(){ var city=document.getElementById("TextBox1").value; <%=ClientScript.GetCallbackEventReference(this,"city","FillDll",null) %> } //填充下拉列表框的方法 function FillDll(strcity) { document.getElementById("DropDownList1").options.length=0; var indexofcity; var city; //切割传递来的字符串 while(strcity.length>0) { //判断是否是最后一个字符串 indexofcity=strcity.indexOf(","); if(indexofcity>0) { city=strcity.substring(0,indexofcity); strcity=strcity.substring(indexofcity+1); //填充下拉列表 document.getElementById("DropDownList1").add(new Option(city,city)); }else { //如果是最后一个字符串 document.getElementById("DropDownList1").add(new Option(strcity,strcity)); break; } } } </script>
                Iframe实现局部刷新
城市名称:      显示区域列表  
在服务器端继承ICallbackEventHander类,生成回调的方法 public partial class CallBack :System.Web.UI.Page,ICallbackEventHandler { private string _data; protected void Page_Load(object sender, EventArgs e) { } //默认生成的回调方法 //#region ICallbackEventHandler 成员 //public string GetCallbackResult() //{ // throw new Exception("The method or operation is not implemented."); //} //public void RaiseCallbackEvent(string eventArgument) //{ // throw new Exception("The method or operation is not implemented."); //} //#endregion //回调事件的服务器方法 public string GetCallbackResult() { //返回处理后的数据; return _data; } public void RaiseCallbackEvent(string eventArgument) { //判断传递来的参数 switch (eventArgument) { case "北京": _data = "朝阳,海定,东城,西城"; break; case "上海": _data = "浦东,静安,虹口,徐汇"; break; case "济南": _data = "历下,历城,市中,天桥"; break; } } }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值