When does Control Id get changed ?

B

Brian Slack

Hi

In CreateChildControls I create a table and give each row an id based on the
record number from a db i.e.
trTwo.ID = "tq" & myRecordSet("QuestionId").ToString

However when it is rendered on the page when the custom control is in a
master page scenario the id is ctl_whatever_someotherjunk_tq1

When is the id changed from what I designed it to be (and if you can tell me
why)



Brian
 
T

Teemu Keiski

Hi,

When is the id changed from what I designed it to be (and if you can tell
me why)

ASP.NET maintains the IDs so that every control has unique id (on server and
on client) within a naming scope (naming container). What you see is the id
for client (given by ClientID server-side property of your control), so that
you can for example uniquely identify the control for javascript.

The complete unique ID consists of IDs of your control's parent controls
which are naming containers plus your control's "local" ID. Naming container
means a control which specifies a naming scope such that all control IDs
within its scope are unique. For example DataGrid/GridView row is such.

Your control does have the ID you specify to it (ther "local" one), but its
the ID which is unique on the current naming scope (within parent of your
control).
 

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,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top