在 ASP.NET 中访问控制客户端名称而不是 ID [英] Accessing control client name and not ID in ASP.NET
本文介绍了在 ASP.NET 中访问控制客户端名称而不是 ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在 JavaScript 中触发服务器端 ASP.NET 按钮点击事件.我检查了页面源代码和客户端的 button
的 onclick
是:
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));
但我必须将 ctl00$LoginInfo1$btnliOK
替换为类似 <%= btnliOK.ClientName %>
的东西.有没有办法做到这一点?
But I have to replace ctl00$LoginInfo1$btnliOK
with something like <%= btnliOK.ClientName %>
. Is there a way to do that?
推荐答案
您可以使用 Control.UniqueID 属性获取它
You can get it using the Control.UniqueID Property
btnliOK.UniqueID
UniqueID
给出页面呈现的名称ClientID
给出页面呈现的 idID
给出你可以在后面的代码上使用的id
这篇关于在 ASP.NET 中访问控制客户端名称而不是 ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文