Accessing control client name and not ID in ASP.NET

时间秒杀一切 提交于 2019-11-26 04:27:56

问题


I want to fire a server-side ASP.NET button click event in JavaScript. I checked the page source and the button\'s onclick in client side is:

WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(\"ctl00$LoginInfo1$btnliOK\", \"\", true, \"\", \"\", false, false));

But I have to replace ctl00$LoginInfo1$btnliOK with something like <%= btnliOK.ClientName %>. Is there a way to do that?


回答1:


You can get it using the Control.UniqueID Property

btnliOK.UniqueID

UniqueID gives the on page rendered name
ClientID gives the on page rendered id
ID give's the id that you can use on code behind



来源:https://stackoverflow.com/questions/5763557/accessing-control-client-name-and-not-id-in-asp-net

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