HTML元素id在运行时更改 [英] HTML element id changes at runtime

查看:98
本文介绍了HTML元素id在运行时更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我有一个ASP.NET网页表单,我一直想知道为什么在运行时ID会更改我的html元素,如果它们放在一个asp:control



例如

Ok i have an ASP.NET web form, i've always wondered why at runtime the ID's change of my html elements if they're placed inside of a asp:control

e.g

<asp:Content ID="Content2" ContentPlaceHolderID="ContentBody"  runat="server">
<img id="produt_image">







在运行时变为




at runtime becomes

<img id="ContentBody_product_image">





为什么会这样做,并且它会影响从后面的代码中命名/调用img框,我会使用product_image或新运行时ID来引用它吗?



why does it do this, and does it affect naming / calling that img box from the code behind, would i ref it using product_image or the newly runtime id?

推荐答案

参考:内容页面中的控件ID命名 [ ^ ]

更多阅读:所有关于ASP.NET中的客户端ID模式4 [ ^ ]
Refer: Control ID Naming in Content Pages[^]
More reading: All about Client ID Mode in ASP.NET 4[^]


这篇关于HTML元素id在运行时更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆