Sys.Application.add_load Fires On Each Callback

ASP.NETAjax comes with a nice way to attach to a load event of a page. To doit just call Sys.Application.add_load and pass it a function as anargument. Done. Everything works as expected... WRONG!

It comes out that add_load fires on each callback and not only whenthe page loads for the first time. That is of course a problem if youwant something to happen on page load only.

From what I've been able to learn, this behavior is by design.Although it is never mentioned in a strigh forward way in a description:

"Raised after all scripts have been loaded and after the objects in the application have been created and initialized."

There are some places in the documentation, that suggests that thisis a way it was intended to be. First of all, ASP.NET Ajax tries tomimic that ASP.NET Page life cycle and as such, fires the load eventevery time there is a callback. The other thing that makes me believe,that load's behavior is there by design is this:

"You can use the event arguments to determine whether the page isbeing refreshed as a result of a partial-page update and whatcomponents were created since the previous load event was raised."

So now I know, but I still cannot accept the naming convention.Sys.Application plainly suggests, it's a kind of singleton, and not aper load thingy.

转载于:https://www.cnblogs.com/CodingPerfectWorld/archive/2010/07/29/1788029.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值