刚才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. <% ... %>).的更多相关文章

  1. 错误:The Controls collection cannot be modified because the control contains code blocks (i.e. ). .

    用 <%# %>这种写法是写在数据绑定控件中的,之所以用 <%= %>会出现The Controls collection cannot be modified because ...

  2. C#错误:The Controls collection cannot be modified

    用 <%# %>这种写法是写在数据绑定控件中的,之所以用 <%= %>会出现The Controls collection cannot be modified because ...

  3. 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 ...

  4. Java - Collection 高效的找出两个List中的不同元素

    如题:有List<String> list1和List<String> list2,两个集合各有上万个元素,怎样取出两个集合中不同的元素? 方法1:遍历两个集合 public ...

  5. java集合框架02——Collection架构与源码分析

    Collection是一个接口,它主要的两个分支是List和Set.如下图所示: List和Set都是接口,它们继承与Collection.List是有序的队列,可以用重复的元素:而Set是数学概念中 ...

  6. ASP.Net Controls 用法大全

    The FindControl method of the System.Web.UI.Control class appears simple enough to use. In fact, the ...

  7. Java容器解析系列(2) 具体化的第一步——Collection到AbstractCollection

    在通向具体化的List,Queue之前,我们需要先了解一下Collection接口和AbstractCollection抽象类,这两个都是处于Collection顶层的存在. Collection接口 ...

  8. Java Collection - 003 高效的找出两个List中的不同元素

    如题:有List<String> list1和List<String> list2,两个集合各有上万个元素,怎样取出两个集合中不同的元素? 方法1:遍历两个集合 public ...

  9. 每日英语:China Grapples With Genetically Modified Foods

    A Chinese agricultural official's unsupported claims about the carcinogenic risks of consuming genet ...

随机推荐

  1. BZOJ4154:[IPSC2015]Generating Synergy

    浅谈\(K-D\) \(Tree\):https://www.cnblogs.com/AKMer/p/10387266.html 题目传送门:https://lydsy.com/JudgeOnline ...

  2. BZOJ1370:[Baltic2003]团伙

    浅谈并查集:https://www.cnblogs.com/AKMer/p/10360090.html 题目传送门:https://lydsy.com/JudgeOnline/problem.php? ...

  3. 洛谷【P2629】好消息,坏消息

    浅谈队列:https://www.cnblogs.com/AKMer/p/10314965.html 题目传送门:https://www.luogu.org/problemnew/show/P2629 ...

  4. MySQL insert插入

    使用INSERT语句插入新数据 语法:INSERT [INTO] tbl_name [(col_name,...)] VALUES (pression,...),…      INSERT [INTO ...

  5. Python 下载图片的几种方法

    import osos.makedirs('./image/', exist_ok=True)IMAGE_URL = "http://image.nationalgeographic.com ...

  6. VisualGDB系列11:Linux C++项目中使用外部Linux库

    根据VisualGDB官网(https://visualgdb.com)的帮助文档大致翻译而成.主要是作为个人学习记录.有错误的地方,Robin欢迎大家指正. 在<使用VS创建Linux静态库和 ...

  7. Ubuntu bash不记录history方法

    很多都是用: unset HISTORY HISTFILE HISTSAVE HISTZONE HISTORY HISTLOG export HISTFILE=/dev/null export HIS ...

  8. Python类(三)-多继承的区别

    多继承的有两个方式,一个是广度优先,一个是深度优先Python2中经典类按深度优先,新式类按广度优先Python3中经典类和新式类都按广度优先 # -*- coding:utf-8 -*- __aut ...

  9. VC用Beep整几首歌听听~~~

    //生日快乐歌 #include "stdafx.h"#include <windows.h>void main(void)   {       unsigned FR ...

  10. How to clear fmadm log or FMA faults log (ZT)

    Here are the step by step of clearing the FMA faults on most of Oracle/Sun server. Work perfectly on ...