ClientID

G

Guest

Hi,

Can anyone advise me how is the ClientID issued?
I had a suite Controls which consist of a context menu (i.e. a group of
tables, rows and cells situated in a class library) and a set of buttons. I
am doing dynamic HTML which I only know how many buttons and context menu to
create on the fly.

Next I had written a simple JAvascript which will allow the dialogs (i.e.
the context menu's tables) to be placed at the correct location when
mouseover event is activated. But I got strange ClientIDs return to me. When
the page is reloaded using the button click event, the clientID of the menu
table's table is in the form of ID. But when the page is activated via a
click event of the table cell in the class library, the the clientID will now
be __clt0_+"ID";

Why is it this way, how asp.net issue clientID to the controls?

Many Thanks!
 
J

Josh Mitts

I'm not exactly sure what you mean by the different client IDs, can you post
an example of the different behavior?

In the meantime, here's some basic information on the ClientID property from
http://msdn.microsoft.com/library/d...frlrfSystemWebUIControlClassClientIDTopic.asp:

<snip>
ASP.NET automatically generates a ClientID for a server control regardless
of whether you have specified an ID property for it or not. This property is
used to identify a control for client-side operations, such as ECMAScript
functions.
Any name you assign to a server control using the ID property overrides the
value of this property.
</snip>

Maybe you aren't assigning an ID to the control on that other case? If you
post some code, that will really help.
 
G

Guest

Hi Josh,

I know what went wrong already. The ClientID is generated by ASP.NET. When
building controls within controls, the clientID will be
parentcontrol.clientID + ID. This appending of IDs wil ensure that the
clientID for a particular control is unique and it also shows the hierarchy
of the controls.

I made a mistake as I took the clientID before adding the control to the
parent. Hence the clientID will be the normal ID value we set for the
control. The appending of the parentID will only happen when
parent.controls.add(control) is called.

Thanks! and sorry for the confusion.
 

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

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top