Control IDs reverse?

Discussion in 'ASP .Net Building Controls' started by JW, Sep 22, 2003.

  1. JW

    JW Guest

    I have a WebControl, lets call it WebC. WebC has a Label control, with
    an ID of TheLabel. I have a UserControl, lets call it UserC. I drop
    WebC onto UserC; WebC has an ID of "WebC1" and the Label on WebC1 now
    has an ID of "WebC1_TheLabel". I drop UserC onto a page; UserC has an
    ID of "UserC1" and the Label on WebC1 now has an ID of
    "UserC1_WebC1_MyLabel". From within the WebC code, there is an area
    that writes the Label control's ID [e.g. this.Attributes.Add(
    "onmouseover", "jsfunction('" + this._theLabel.ID + "');"]. Okay, so
    when the control renders the onmouseover event SHOULD look something
    like this:

    onmouseover="jsfunction('UserC1_WebC1_MyLabel');"

    But instead it comes out like this:

    onmouseover="jsfunction('WebC1_UserC1_MyLabel');"

    It reverses WebC1 with UserC1 in the naming container. Why does this
    happen and how do you correct it?

    -James
    JW, Sep 22, 2003
    #1
    1. Advertising

  2. I answered my own question. I needed to use ClientID instead ID.


    "JW" <> wrote in message
    news:...
    > I have a WebControl, lets call it WebC. WebC has a Label control, with
    > an ID of TheLabel. I have a UserControl, lets call it UserC. I drop
    > WebC onto UserC; WebC has an ID of "WebC1" and the Label on WebC1 now
    > has an ID of "WebC1_TheLabel". I drop UserC onto a page; UserC has an
    > ID of "UserC1" and the Label on WebC1 now has an ID of
    > "UserC1_WebC1_MyLabel". From within the WebC code, there is an area
    > that writes the Label control's ID [e.g. this.Attributes.Add(
    > "onmouseover", "jsfunction('" + this._theLabel.ID + "');"]. Okay, so
    > when the control renders the onmouseover event SHOULD look something
    > like this:
    >
    > onmouseover="jsfunction('UserC1_WebC1_MyLabel');"
    >
    > But instead it comes out like this:
    >
    > onmouseover="jsfunction('WebC1_UserC1_MyLabel');"
    >
    > It reverses WebC1 with UserC1 in the naming container. Why does this
    > happen and how do you correct it?
    >
    > -James
    >
    James Williams, Sep 22, 2003
    #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?Tmljaw==?=

    generate control IDs dynamically

    =?Utf-8?B?Tmljaw==?=, Jun 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    406
    Trevor Benedict R
    Jun 13, 2004
  2. David
    Replies:
    2
    Views:
    310
    Saravana [MVP]
    Jul 12, 2004
  3. Nate Hekman

    control ids

    Nate Hekman, Dec 2, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    377
    Matt Berther
    Dec 3, 2004
  4. dogbite
    Replies:
    4
    Views:
    692
    osmium
    Oct 10, 2003
  5. Replies:
    2
    Views:
    701
    Beat Bolli
    Jun 21, 2005
Loading...

Share This Page