在另一个 GridView 中: ' runat="server" /> -6ren">
gpt4 book ai didi

c# - 重复 ID 是否会导致有关 View 状态的随机错误?

转载 作者:行者123 更新时间:2023-11-30 22:18:35 26 4
gpt4 key购买 nike

asp.net 接受不同模板字段中 asp.net 服务器控件的重复 ID。

<ItemTemplate>
<asp:HiddenField ID="HDN_MainCode" Value='<%#Eval("v_main_code")%>' runat="server" />
</ItemTemplate>

在另一个 GridView 中:

<ItemTemplate>
<asp:HiddenField ID="HDN_MainCode" Value='<%#Eval("v_main_code")%>' runat="server" />
</ItemTemplate>

这种类型的重复会导致有关 View 状态的随机错误吗?如果答案是肯定的,我如何检测 .aspx 文档

中的所有重复项

最佳答案

Could this type of repeating cause random errors concerning viewstate ?

没有。这些内部控件在呈现时获得一个唯一 ID。例如,如果您的 ListView 中有标签 ID ProductIDLabel,那么其生成的 ID 将类似于:

ListView1$ctrl0$ProductIDLabel
ListView1$ctrl1$ProductIDLabel

有关更多信息,请参阅:ASP.NET Web Server Control Identification

When the control is inside a data-bound control that creates multiple instances of the control, the value that you assign to the ID property is concatenated with the naming container and with an incrementing index.

但是如果你有 ClientIDMode设置为Static,那么您将获得与在ASPX 页面中指定的ID 相同的ID。

关于c# - 重复 ID 是否会导致有关 View 状态的随机错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16011804/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com