Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing control client name and not ID in ASP.NET

Tags:

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?

like image 338
nima Avatar asked Apr 23 '11 10:04

nima


1 Answers

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

like image 123
Aristos Avatar answered Oct 23 '22 05:10

Aristos