惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - 浙林龙哥

S3 put object upload file,被AI欺骗的一天 How to get blob data using javascript XmlHttpRequest by sync 咖啡之约--体验 SourceAnywhere 安装node.js / npm / express / KMC 选择沃阁橱柜 VS 2010 和 .NET 4.0 系列之《ASP.NET 4 Web Forms 的整洁HTML标识 — 客户端ID》篇 .NET 3.5 Ruby学习1-字符串 ImageMagick 详细安装使用 linux (jmagick) Windows XP 上安装 Bind9 BIND9配置 [javascript] 数组去重问题 [javascript]数组去重 数组A和B找交集 淘宝图片空间---设计师可免费申请短链接啦! php框架 How to use iBatis/NHibernate in medium trust/partial trust environments like Mosso JVM调优 常用的eclipse plugins
ASP.NET 4.0的ClientIDMode=”Static”未必是最好
浙林龙哥 · 2012-05-02 · via 博客园 - 浙林龙哥

ASP.NET 4.0新增的ClientIDMode是一項重大的更新,不知這是什 的話,可以在這裡看看。 預設ClientIDMode是Inherit 不過我想大多數人都會把焦點放在ClientIDMode=”Static”。

由於預設是Inherit,ClientIDMode會以預設的AutoID去制定Controls ID,或者有人會直接在Page Detective把ClientIDMode設定為”Static”供ClientIDMode去Inherit。

<%@Page ClientIDMode="Static"%>

那就不用每個WebControl都設定一次,但問題就來了,部份Third Party的WebControls未必能可以在Static ID下運作,特別是需要ClientScript做CallBack的,可能會找不到Render HTML後的ID。 目前至少AjaxControltoolKit中的AsyncFileUpload已經要設定ClientIDMode=”AutoID”才能正確運作。

而值得看看的是Predictable Mode,Predictable 主要是給Data Control使用,例如Repeater,DataList這些會重複Generate HTML Element的WebControls。 因為當你制定ItemTemplate時,你不可能期望每一項Item中的Controls ID都相同,同樣亦不合理,例如Repeater:

 <tr>
   <td>
     <span id="mySpan">Row1</span>
   </td>
 </tr>
 <tr>
   <td>
     <span id="mySpan">Row2</span>
   </td>
 </tr>

所以”Predictable”的出現就是給你設定ClientIDRowSuffix property,自行制定。其實我會建議在DataControl中ItemTemplate或EditTemplate下,所有Web Control都加上ClientIDMode為AutoID或者Predictable,即使設成AutoID感覺上很多餘,但基於有override的可能性,都是加上好一點。

或者ASP.NET老手已經深明這些道理,但剛學ASP.NET的話,亦無需要太追求簡短的ID,這類型ID,”ctl00_ContentPlaceHolder1_HideProductImage”,我們都習慣了。