ASP.NET 4.0 ListView等容器控件中获取ClientID值与HTML中自动生成ID字符串不一样问题。
2024-10-19 14:32:06
ASP.NET 4.0 中 ClientIDMode的属性 可以设置获取不同ID格式的值。
项目中遇到的问题:
1、ListView1 ItemDataBound事件中,获取ClientID结果与自动生成ID一致。
2、ItemDataBound事件中不执行InsertItemTemplate段。(获取Insert中控件ID无法获取)
所以还得通过在ItemCreated时获取ClientID。结果后台中获取值与最终HTML自动生成ID字符串有差异。
解决方法:
在父容器控件ListView1的ClientIDMode值设为Static (ClientIDMode="Static")
其模板中控件TextBox的ClientIDMode值设为Predictable (ClientIDMode="Predictable ")
结果一致“ctrl0_LogoURLTextBox_0” 自动生成ID也不带父容器ID。
最新文章
- no module named flask.ext.login
- 5、Servlet的使用
- 未能加载文件或程序集“System.Data.SQLite”或它的一个依赖。试图加载格式不正确的程序
- 速战速决 (2) - PHP: 数据类型 bool, int, float, string, object, array
- .NET下金额大小写转换
- ChRoomtst
- IOS cocos2d笔记1
- JAVA_基础面试题
- Visual Studio Team Services使用教程--默认团队checkin权限修改
- HUST - 1599 Multiple
- git push解决办法: ! [remote rejected] master ->; master (pre-receive hook declined)
- 使用alembic进行数据库版本管理
- 一个简单的cmake例子
- 有关svn的报错
- LeetCode--028--实现strStr() (java)
- python两个列表合并为字典,一个作为key,一个作为value
- php date_default_timezone_set()设置时区
- gitlab 502 报错
- 打开Delphi 10.1 berlin提示脚本错误的解决方法
- 标准标签、<;jsp:include>;、<;jsp:forward>;