当前位置: 动力学知识库 > 问答 > 编程问答 >

html - Underscore plus numeric sequence value being appended to end of element id

问题描述:

Does anybody know why this would be happening?

I have an aspx page that has data populated by a repeater. For some reason a numeric sequence value is being appended to all element ids that are being created by .net. Examples of element ids.

id="SearchResults_rep_ChkBoxSelectRecord_ID_100001_0"

id="SearchResults_rep_ChkBoxSelectRecord_ID_100002_1"

id="SearchResults_rep_ChkBoxSelectRecord_ID_100003_2"

id="SearchResults_rep_ChkBoxSelectRecord_ID_100004_3"

However, the element names do not have the extra value appended:

name="SearchResults_rep_ChkBoxSelectRecord_ID_100001"

name="SearchResults_rep_ChkBoxSelectRecord_ID_100002"

name="SearchResults_rep_ChkBoxSelectRecord_ID_100003"

name="SearchResults_rep_ChkBoxSelectRecord_ID_100004"

The ids are assigned dynamically in the codebehind from an integer. ...and this does not happen when running locally, but is happening on our staging server. I am aware of the ClientIDMode if I wanted to not use the .net id auto naming convention, but it would require too many code changes if I changed that property now. I am running into wall as to why this is happening. Any ideas?

More info in case it is relevant. The staging server is running Windows Server 2003 with IIS 6

网友答案:

I did end up discovering a solution to this issue, it had to do with upgrading code from .net 2.0 to 4.0 and the default value of the ClientIDMode, which for .net 4.0 is Predictable.

Adding <pages clientIDMode="AutoID"> to the System.Web node in the web.config resolved the issue.

分享给朋友:
您可能感兴趣的文章:
随机阅读: