ASP.NET回调 [英] ASP.NET callback

查看:71
本文介绍了ASP.NET回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个示例ASP.NET(2.0)表单来演示回调脚本.回调链接到下拉列表的OnChange事件.

问题是,回调仅在我第一次更改下拉列表时触发.对于下拉列表中会话中的所有其他onchange事件,不会触发回调.我究竟做错了什么 ?这与Javascript脚本函数在ASP html页面中的放置有关吗?

另一个令人困惑的事情是,在我的页面加载中,我检查是否正在发生Page.IsPostback或Page.IsCallBack .但是调试这表明代码在执行onChange时会同时通过Page.IsCallback和Page.IsPostback传递!我相信它们是互斥的(例如,如果发生回调,那么回发就不能,反之亦然).

作为ASP.NET的新成员,我需要您对此领域的见识.

我的页面实现了 ICallbackEventHandler ,它具有 RaiseCallbackEvent& GetCallbackResult函数,这就是我如何将它们全部整合到PageLoad

stat = " ;

I have written a sample ASP.NET ( 2.0) form to demo callback scripting. The callback is linked to the OnChange event of a dropdownlist.

Problem is that the callback fires only the first time I do a change to the dropdownlist. For all other onchange events in the session on the dropdownlist, the callback does not fire. What am I doing wrong ? Has this got to do with the placement of the Javascript script function in the ASP html page ?

Another confusing thing is that on my Page load I check whether a Page.IsPostback or Page.IsCallBack is taking place. But debugging this indicates that the code passes thru both Page.IsCallback and Page.IsPostback while doing the onChange !! I believed that these were mutually exclusive ( i.e if a callback is happening then a postback cannot and vice versa) .

As a new ASP.NET entrant,  I need your insights into this area.

My Page implements the ICallbackEventHandler , it has RaiseCallbackEvent & GetCallbackResult functions and this is how I put it all together in the PageLoad

static string stat = "";

 

受保护的 Page_Load( 发件人 e)

{

protected void Page_Load(object sender, EventArgs e)

{

如果 (Page.IsCallback)

{

if (Page.IsCallback)

{

tb2.Text =

tb2.Text =

"CB" ;

}

"CB";

}

如果 (Page.IsPostBack)

{

if (Page.IsPostBack)

{

tb2.Text =

tb2.Text =

"PB" ;

}

"PB";

}

如果 (!Page.IsPostBack)

{

if (!Page.IsPostBack)

{

tb2.Text =

tb2.Text =

"" ;

"";

 

字符串callbackeventreference = Page.ClientScript.GetCallbackEventReference(this,"document.all ['ddl1'].value","CallbackFunction" ;,"null");

ddl1.Attributes [

ddl1.Attributes[

"onChange" ] = callbackeventreference;
}

}

"onChange"] = callbackeventreference;
}

}



非常感谢.



Thanks plenty.

推荐答案


首页


这篇关于ASP.NET回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆