在UpdatePanel中使用Menu出错的解决方案
来源:互联网 发布:vb获取硬盘物理序列号 编辑:程序博客网 时间:2024/05/23 01:20
在atlas的时候,在UpdatePanel中使用Menu控件是不会出错的,但是正式命名为asp.net ajax后,从beta1开始,在UpdatePanel 中就无法正常使用Menu控件了,一直到RTM也没有解决这个问题。在asp.net ajax的官方文档中也有这样的说明(原文http://ajax.asp.net/docs/overview/UpdatePanelOverv...):
The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside an UpdatePanel control:
-
TreeView and Menu controls.
-
Web Parts controls. For more information, see ASP.NET Web Parts Controls.
-
FileUpload controls when they are used to upload files as part of an asynchronous postback.
-
GridView and DetailsView controls when their EnableSortingAndPagingCallbacks property is set to true. The default is false.
-
Login, PasswordRecovery, ChangePassword, and CreateUserWizard controls whose contents have not been converted to editable templates.
-
The Substitution control.
-
Validation controls, which includes the BaseCompareValidator, BaseValidator, CompareValidator, CustomValidator, RangeValidator, RegularExpressionValidator, RequiredFieldValidator, and ValidationSummary control.
其它几个控件都有前提条件,唯独TreeView,Menu和WebParts控件都不支持。那是不是真的就没有办法了呢?
目前只遇到Menu无法使用,先来回放一下在UpdatePanel中使用Menu控件会出现什么样的脚本错误呢?
我是用Menu和MultiView来实现Tab控件的效果,但是在UpdatePanel中,首次转换选项页不会出错,但当我再次将鼠标移到选项按钮时就会出现:
'0.cells'为空或不是对象 的脚本错误提示。跟踪调试错误脚本
at http://localhost:15159/WebResource.axd?d=YEs0K3CeKJkuxCHKobf0Fg2&t=633046464802812500 [220]
Menu_HideItems
code: i < rows[0].cells.length
at http://localhost:15159/WebResource.axd?d=YEs0K3CeKJkuxCHKobf0Fg2&t=633046464802812500 [525]
Menu_SetRoot
code: Menu_HideItems()
at http://localhost:15159/WebResource.axd?d=YEs0K3CeKJkuxCHKobf0Fg2&t=633046464802812500 [39]
Menu_Expand
code: Menu_SetRoot(item)
at http://localhost:15159/WebResource.axd?d=YEs0K3CeKJkuxCHKobf0Fg2&t=633046464802812500 [297]
Menu_HoverStatic
code: Menu_Expand(node, data.horizontalOffset, data.verticalOffset)
at http://localhost:15159/MasterPage.aspx [26]
JScript - form1 anonymous function
code: el="stylesheet" /><lin
会发现是在Menu_HideItems函数内部出错了。可以根据脚本资源地址下载到脚本文件,得到Menu_HideItems原型定义。然后利javascript的却态特性,我们可以重写这个方法,来屏蔽这个错误。在官方论坛上找到这样一段js代码,把它拷到出错的页面上,就马上可以解决这个问题了。
var oldMenu_HideItems = Menu_HideItems;if(oldMenu_HideItems){Menu_HideItems = function(items){if (!items || ((typeof(items.tagName) == "undefined") && (items instanceof Event))) { items = __rootMenuItem; }if(items && items.rows && items.rows.length == 0){ items.insertRow(0); }return oldMenu_HideItems(items);}}
原文地址是:http://forums.asp.net/thread/1517884.aspx
我不知道这种办法能否也同样用在TreeView出错时,因为我没有在UpdatePanel中使用过TreeView。不过这种办法确实给我提供了解决控件内部js脚本错误的一个很好的思路。
- 在UpdatePanel中使用Menu出错的解决方案
- 在UpdatePanel中使用Menu出错的解决方案
- 在使用UpdatePanel时JS对话框出错的解决办法
- 解决在asp.net中 使用 ajax UpdatePanel出现乱码问题的解决方案
- AJAX&.NET下在母版页中使用UpdatePanel的解决方案
- 在Updatepanel中使用JS的问题.
- 在Updatepanel中使用JAVASCRIPT的问题
- CxImage在使用中delete出错的解决方案
- 在Updatepanel中使用JAVASCRIPT的问题(转)
- 在updatepanel中使用response时需要配置的信息
- JQUERY的效果在UpdatePanel中控件回发后失效的解决方案
- ReportViewer 9.0在UpdatePanel控件中产生Javascript错误的两种解决方案
- .net4.0环境下UpdatePanel在iphone下无法正常使用的解决方案
- 在母版页中使用UpdatePanel
- 在母版页中使用UpdatePanel
- 在Updatepanel中使用Response.Redirect
- 在Fragment中使用Menu
- 在活动中使用menu
- Sql2005带来的分页便利
- 使用J2SE API读取Properties文件的六种方法
- asp.net 2.0 下的表单验证Cookieless属性
- OracleSQL内置函数大全之二
- VC多媒体编程
- 在UpdatePanel中使用Menu出错的解决方案
- 无锡青年人才大市场成立庆典仪式暨无锡市2007年庆"五四"综合大型人才招聘会
- 在b/s开发中经常用到的javaScript技术整理
- 调用加了SSL签名的WebService
- 一些非常有用的备忘录文档
- OracleSQL内置函数大全之三
- 如何判断GridView控件的某一行是否被选中
- 不同编码引发的QueryString传参乱码
- Windows Genuine Advantage