Zhi-QiangNi's tech blog--AJAX's paradise
I'm working at the Microsoft IBS DevDiv Community Support Team, in charge of the customer service of ASP/AJAX forum. Welcome to my blog and AJAX forum, anyone interested in ASP.Net Ajax can discuss it with me. :-)
posts - 11,  comments - 24,  trackbacks - 1

We all know the Extenders of the AjaxControlToolkit implement their Client Partial-Refresh action by using their Client behaviors which are generated after they are rendered. In addition, the client classes provide many useful APIs that enable you to bind to events and to provide handlers for those events.

For example, the AutoComplete Extender's client behavior document would like this:

The AutoCompleteExtender

Code

Its Client Behaviior Document

You may notice that we simply used this method "$find(the Extender's BehaviorID)" to get the Client Behavior Document. If the BehaviorId is not defined, we can use this "$find(<%=the Extender's ClientID%>)".

But sometimes things are not so simple. If we place the Extender inside a DataBind Control's ItemTemplete, such as GridView. The same method would raise error which sames like this:

Sys.InvalidOperationException:Two components with the same id 'XXXXXBehavior1' can't be added to the application.

That's because the BehaviorId shoule be unique.

Then, how can we get the Behaviors in this situation?

Actually, every behavior has been cached into the Sys.Application's Components object after the page client initialize phase in the Life-Cycle. When script in a load event handler runs, all scripts and components have been loaded and are available. That's the key to achieve our goal.

Code

 

 


作者:Zhi-QiangNiZhi-QiangNi's Tech Blog
出处:http:// Zhi-QiangNi.cnblogs.com/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

posted on 2009-01-15 14:52 Zhi-Qiang Ni 阅读(1246) 评论(2) 编辑 收藏

FeedBack:
2009-01-15 15:42 | 账号难注册      
哦,呵呵,不错
 回复 引用 查看   
#2楼[楼主]
2009-01-15 15:46 | Zhi-Qiang Ni      
@账号难注册
Thanks.

 回复 引用 查看   

翻译

昵称:Zhi-Qiang Ni
园龄:3年
粉丝:0
关注:0

<2009年1月>
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

搜索

 

常用链接

随笔分类

随笔档案

积分与排名

  • 积分 - 9158
  • 排名 - 9199

最新评论

阅读排行榜

评论排行榜

推荐排行榜