Problem with INamingContainer

S

Sergio FLorez M.

I created a composite control which works just fine. I want to be able to
set the focus to one of its contained controls (a textbox) but this is
giving me a javascript error. The problem is that the ClientID property of
the contained textbox is not giving me the correct value. When I debug the
application the contained textbox's ClientID is "myControl__ctl1", but when
I look at the generated HTML the input tag looks like this: <input
name="myControl:_ctl1" ... />

How did the first "_" turn into ":" and how do I fix this?
 
L

lisa

You don't, really. The ID will be NamingContainerID_ChildID, and the
name will be NamingContainerID:ChildID. That's just the way it works.
If you're using Javascript, you could do
document.getElementById(ClientID).focus()

Otherwise, you're going to have to override Render and manually set the
name equal to the id. That's a pain, and unnecessary.

Lisa
 
S

Sergio FLorez M.

Actually, that's exactly what I was using -
document.getElementById(ClientID).focus()

The solution is really simple. Instead of ClientID I have to use UniqueID.

--
Sergio Florez M.
Medellín, Colombia

You don't, really. The ID will be NamingContainerID_ChildID, and the
name will be NamingContainerID:ChildID. That's just the way it works.
If you're using Javascript, you could do
document.getElementById(ClientID).focus()

Otherwise, you're going to have to override Render and manually set the
name equal to the id. That's a pain, and unnecessary.

Lisa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top