search for ClientID client-side or server-side?

廉价感情. 提交于 2019-12-12 01:16:56

问题


I understand that I currently can't use <a onclick="alert('<%=TextBox1.ClientID%>')" directly because I need to access it in a table cell in a table in the EditTemplate of a DataList inside a UserControl.

That said, I need to recursively check the controls to get the ClientID, should it be done
client-side: alert(getMyElement('TextBox1').id), where getMyElement checks all elements of the form and returns the control with the id...or
server-side: alert('<%=FindElement(dlDataList, "TextBox1").ClientID%>') where FindElement is a base page function that checks the controls of the first param for an element with an id of the second param and returns that control ?

I'm figuring the client-side would be faster?


回答1:


I always go with server side for this case. Otherwise you're traversing the entire DOM with each row - depending on the size, it could be a memory hog. Server side takes almost no resources for this.



来源:https://stackoverflow.com/questions/1589548/search-for-clientid-client-side-or-server-side

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