The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
刚才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图片,区别,只是图片名称不同而已。重构一下:
看看动态变更网页背景图片:
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 ...
- C#错误:The Controls collection cannot be modified
用 <%# %>这种写法是写在数据绑定控件中的,之所以用 <%= %>会出现The Controls collection cannot be modified because ...
- The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.
https://stackoverflow.com/questions/5508666/dynamically-add-html-to-asp-net-page https://stackoverfl ...
- Java - Collection 高效的找出两个List中的不同元素
如题:有List<String> list1和List<String> list2,两个集合各有上万个元素,怎样取出两个集合中不同的元素? 方法1:遍历两个集合 public ...
- java集合框架02——Collection架构与源码分析
Collection是一个接口,它主要的两个分支是List和Set.如下图所示: List和Set都是接口,它们继承与Collection.List是有序的队列,可以用重复的元素:而Set是数学概念中 ...
- ASP.Net Controls 用法大全
The FindControl method of the System.Web.UI.Control class appears simple enough to use. In fact, the ...
- Java容器解析系列(2) 具体化的第一步——Collection到AbstractCollection
在通向具体化的List,Queue之前,我们需要先了解一下Collection接口和AbstractCollection抽象类,这两个都是处于Collection顶层的存在. Collection接口 ...
- Java Collection - 003 高效的找出两个List中的不同元素
如题:有List<String> list1和List<String> list2,两个集合各有上万个元素,怎样取出两个集合中不同的元素? 方法1:遍历两个集合 public ...
- 每日英语:China Grapples With Genetically Modified Foods
A Chinese agricultural official's unsupported claims about the carcinogenic risks of consuming genet ...
随机推荐
- 推荐几本学习MySQL的好书
转载:http://mingxinglai.com/cn/2015/12/material-of-mysql/ 我这里推荐几本MySQL的好书,应该能够有效避免学习MySQL的弯路,并且达到一个不错的 ...
- BZOJ2038:[2009国家集训队]小Z的袜子
浅谈莫队:https://www.cnblogs.com/AKMer/p/10374756.html 题目传送门:https://lydsy.com/JudgeOnline/problem.php?i ...
- Python 设计一个简单的计算器
设计目标 实现加减乘除及拓号优先级解析 用户输入'1 - 2 * ( (6-3 +(-5/5)*(9-2*3/3 + 7/3*7/4*12 +10 * 5/5 )) - (-4*3)/ (12-3*2 ...
- Laravel 传递数据到视图
// 使用传统的方法 $view = view('greeting')->with('name', 'Victoria'); // 使用魔术方法 $view = view('greeting') ...
- mongo之map-reduce笔记
package com.sy.demo; import com.mongodb.MongoClient; import com.mongodb.client.FindIterable; import ...
- java代码继承。。。找出不能继承父类方法的问题
总结:当子类中没有定义name属性时,在子类的无参构造方法中,父类的姓名是不能被继承的. 输出的结果是,子类无参构造方法里的属性值,也就是是属 控制台显示: 我叫:周杰伦,今年:2岁我的姓名:周杰伦, ...
- HAproxy+Mycat
haproxy+mycat搭建haproxy server 10.0.1.134mycat server 10.0.1.134,10.0.1.135mysql master 10.0.1.134mys ...
- asp.netcore di 实现批量接口注入
废话少说,先上代码 public static Dictionary<Type, Type[]> GetImpleAndInterfaces(string assemblyName,str ...
- python学习笔记(二):python数据类型
上一篇博客写了python的入门和简单流程控制,这次写python的数据类型和各种数据类型的内置方法.一.数据类型是什么鬼?计算机顾名思义就是可以做数学计算的机器,因此,计算机程序理所当然地可以处理各 ...
- 第八章 Java中的并发工具类
等待多线程完成的CountDownLatch countDownLatch允许一个或多个线程等待其他线程完成操作. public class CountDownLatchTest { static C ...