Groups | Blog | Home
all groups > asp.net building controls > june 2005 >

asp.net building controls : Problem with INamingContainer


lisa NO[at]SPAM starways.net
6/20/2005 8:24:40 AM
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


[quoted text, click to view]
Sergio FLorez M.
6/20/2005 9:40:20 AM
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?

--
Sergio Florez M.
Medellín, Colombia

Sergio FLorez M.
6/20/2005 11:04:45 AM
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

[quoted text, click to view]
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


[quoted text, click to view]

AddThis Social Bookmark Button