Is there any drawback to set ClientIDMode = Static on every object ( set on maincontent of master page)

人盡茶涼 提交于 2019-11-27 21:06:38

You want to be careful about setting the ClientIDMode to Static for things like user controls, or you could end up with multiple elements with the same ID.

For data-bound controls like GridView, you'll also want to use the ClientIDRowSuffix property in order to ensure each row is differentiated.

This post has some good examples.

Krishna Tummalapalli

Another way to deal with the IDs in JavaScript would be to do something like this:

var something = '<%= btnId.ClientID %>';

Example: If you have a button control like this:

<asp:Button ID="btnId" runat="server"></asp:Button>    

and the ID is translated to id="ct100_ContentPlaceHolder1_btnId" then you could use the variable something to access the control.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!