Over riding the Default ClientId Property

Discussion in 'ASP .Net Building Controls' started by Elizabeth Harmon, Jun 8, 2004.

  1. Hi All

    When .Net Creates User Controls on a Webpage, it appends a prefix seperated
    by a Colon or an underscore then the Id of the server Control within that
    User Control:

    ex:

    <asp:Dropdownlist id="DDLList" runat="server"></asp:DropDownList> in design
    mode

    <asp:Dropdownlist name="_ctrl0:DDLList" id="_ctrl0_DDLList"
    runat="server"></asp:DropDownList> in run mode

    I try to change the ID by setting the property of the DropDownList like
    this:

    DDLList.Id = "cmbDDLList"

    But .Net retains the naming convention. Is there a way to get around this or
    is this just what .Net Does?

    if i use a placeholder and then Create the Object programmatically, i can
    assign an ID and it keeps the name i assigned to the property.

    I just thought after dragging and dropping there was a way on a user control
    to retain the original Id i typed in for the Server control i droppped
    there.

    thanks in advance
    Elizabeth Harmon, Jun 8, 2004
    #1
    1. Advertising

  2. "Elizabeth Harmon" <> wrote in message
    news:...
    > Hi All
    >
    > When .Net Creates User Controls on a Webpage, it appends a prefix

    seperated
    > by a Colon or an underscore then the Id of the server Control within that
    > User Control:
    >
    > ex:
    >
    > <asp:Dropdownlist id="DDLList" runat="server"></asp:DropDownList> in

    design
    > mode
    >
    > <asp:Dropdownlist name="_ctrl0:DDLList" id="_ctrl0_DDLList"
    > runat="server"></asp:DropDownList> in run mode
    >
    > I try to change the ID by setting the property of the DropDownList like
    > this:
    >
    > DDLList.Id = "cmbDDLList"
    >
    > But .Net retains the naming convention. Is there a way to get around this

    or
    > is this just what .Net Does?
    >
    > if i use a placeholder and then Create the Object programmatically, i can
    > assign an ID and it keeps the name i assigned to the property.
    >
    > I just thought after dragging and dropping there was a way on a user

    control
    > to retain the original Id i typed in for the Server control i droppped
    > there.


    Don't sweat the ID. It will be prefixed if it is placed within another
    control which implements INamingContainer. It's best to leave this issue
    alone and find another way to accomplish your task.
    --
    John Saunders
    johnwsaundersiii at hotmail
    John Saunders, Jun 8, 2004
    #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. Maras
    Replies:
    1
    Views:
    3,112
    Cowboy \(Gregory A. Beamer\)
    Oct 15, 2003
  2. Michael Borgwardt

    Re: Over-riding equals method dilemma

    Michael Borgwardt, Aug 14, 2004, in forum: Java
    Replies:
    23
    Views:
    722
    Chris Uppal
    Aug 23, 2004
  3. Ian Davies

    Link style over riding another

    Ian Davies, Apr 24, 2006, in forum: HTML
    Replies:
    5
    Views:
    448
    Toby Inkster
    Apr 25, 2006
  4. Brian Salter-Duke

    Over-riding an error

    Brian Salter-Duke, May 2, 2009, in forum: C Programming
    Replies:
    21
    Views:
    2,232
    Richard Bos
    May 9, 2009
  5. John
    Replies:
    4
    Views:
    352
Loading...

Share This Page