The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
来源:互联网 发布:sqlserver 字段别名 编辑:程序博客网 时间:2024/04/20 17:29
刚才Insus.NET有尝试改一段代码,是让用户能动态变更网页背景图片的小功能。当Insus.NET去执行铵钮Click事件时,它却出现标题的错误。
代码是这样的:
此代码,原本是没有什么问题的,但现在添加了#6行代码,即是一个铵钮。当执行click事件,它就出现异常了。 Click事件代码是这样的:
怎样解决呢?
最终在网上找到一个方法:
http://leedumond.com/blog/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks/
大约如下(英文):
Insus.NET所理解的,把 "=" 换为"#",然后去Page_load事件中作数据绑定。
在Page_load事件中:
OK,果然能解决此问题。
不过,Insus.NET想使用自己的方法来解这个问题。
去除网页head节点的样式:
去网页.aspx.cs的Page_Load拿掉那一句:Page.Header.DataBind();
并添加一个方法 protected override void OnInit(EventArgs e)
铵钮的Click事件没有改变:
#A图片与#B图片,区别,只是图片名称不同而已。重构一下:
看看动态变更网页背景图片:
<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- The Controls collection cannot be modified because the control contains code blocks (i.e. ).
- 错误:The Controls collection cannot be modified because the control contains code blocks (i.e. ).
- 解决 The Controls collection cannot be modified because the control contains code blocks (i.e. )问题
- The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
- The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
- The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
- 错误:The Controls collection cannot be modified because the control contains code blocks (i.e. ).
- The image cannot be displayed because it contains errors
- The file contains a character that cannot be represented in the current code page (936)
- warning C4819: The file contains a character that cannot be represented in the current code page
- VSE: The file contains a character that cannot be represented in the current code page (936).
- warning C4819: The file contains a character that cannot be represented in the current code page
- warning C4819: The file contains a character that cannot be represented in the current code page
- warning C4819: The file contains a character that cannot be represented in the current code page
- The problem of “Can’t exit design mode because control ‘ShockwaveFlash1’ cannot be created.”
- cannot be opened because the project file cannot be parsed
- cannot be opened because the project file cannot be parsed
- The ActiveX Control cannot be instantiated 解决方法
- vmware环境下linux系统中安装sendmail服务器
- 如何将session数据保存到memcache中,以及memcache的生存周期
- 探索并发编程(六)------Java多线程性能优化
- struts2更改配置文件目录
- hive原理学习
- The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)
- 如何在Linux使用Eclipse + CDT开发C/C++程序?
- asp.net 中javascript的引用
- 探索并发编程(七)------分布式环境中并发问题
- Search the Nth element of Level M in a binary tree
- Ubuntu12.10 下搭建基于KVM-QEMU的虚拟机环境(一)
- memcached-client操作
- TStringList中的Delimiter、DelimitedText用法
- 对一个大型工程的makefile编写的一点思考