When does Control Id get changed ?

Discussion in 'ASP .Net Building Controls' started by Brian Slack, Dec 10, 2005.

  1. Brian Slack

    Brian Slack Guest

    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
     
    Brian Slack, Dec 10, 2005
    #1
    1. Advertising

  2. Brian Slack

    Teemu Keiski Guest

    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).

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    http://blogs.aspadvice.com/joteke
     
    Teemu Keiski, Dec 10, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?bGFuZW0=?=
    Replies:
    1
    Views:
    328
    Juan T. Llibre
    Oct 6, 2005
  2. Replies:
    1
    Views:
    685
    Rosanne
    Oct 11, 2005
  3. Vincent Scheel
    Replies:
    0
    Views:
    426
    Vincent Scheel
    Mar 20, 2006
  4. Vincent Scheel

    ControlDesigner does not "repaint" control when properties are changed

    Vincent Scheel, Mar 20, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    164
    Vincent Scheel
    Mar 20, 2006
  5. mxbrunet
    Replies:
    1
    Views:
    215
Loading...

Share This Page