How can I find out a control's id (name)?

hrabia

Well-known member
Joined
May 21, 2003
Messages
107
Location
Hamburg, Germany
I have one contol ctlLoader which loads second control ucComment. The second control has one textbox txtNewComment. Id like to set focus on my textbox. Ive look at rendered code and find out that my controls id is

ctlLoader__ctl0_ucComment_txtNewComment

so I can set focus like this (client-side javascript):

document.frmDefault.ctlLoader__ctl0_ucComment_txtNewComment.focus();

But how can I get this id programatically?
 
*scratches head*

If all you want to do is set the focus to a control then why would you need the ID? Cant you just do a simple txtNewComment.Focus() ?
 
The client-side ID for a specific control is stored in the Control.ClientID property. This ID can be used with the W3C DOM and JavaScript, which is what youre looking for.
 
Back
Top